Skip to content

Commit

Permalink
Modify CPID local hasher to eliminate compiler warnings on 32 bit archs
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescowens committed Apr 18, 2024
1 parent f9cbaf4 commit 54cfc9f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/gridcoin/cpid.h
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ struct hash<GRC::Cpid>
//!
//! \return A hash as the sum of the two halves of the bytes in the CPID.
//!
/*
size_t operator()(const GRC::Cpid& cpid) const
{
// Just convert the CPID into a value that we can store in a size_t
Expand All @@ -484,6 +485,25 @@ struct hash<GRC::Cpid>
return ret;
}
*/

size_t operator()(const GRC::Cpid& cpid) const
{
// Just convert the CPID into a value that we can store in a size_t
// object. CPIDs are already unique identifiers.
//
const auto& data = cpid.Raw();

size_t ret = 0;

for (size_t i = 0; i < sizeof(size_t); ++i) {
ret |= (size_t)(data[i] & 255) << (i * 8);
}

return ret;
}


};
}

Expand Down

0 comments on commit 54cfc9f

Please sign in to comment.