Skip to content

Commit

Permalink
Make 32 bit hashes take 64 bit seeds as well
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Nov 11, 2024
1 parent 18d6412 commit 4279b22
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mulxp_hash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,12 @@ inline std::uint64_t mul32( std::uint32_t x, std::uint32_t y )
return (std::uint64_t)x * y;
}

inline std::uint32_t mulxp1_hash32( unsigned char const * p, std::size_t n, std::uint32_t seed )
inline std::uint32_t mulxp1_hash32( unsigned char const * p, std::size_t n, std::uint64_t seed )
{
std::uint32_t const q = 0x9e3779b9U;
std::uint32_t const k = q * q;

std::uint64_t h = mul32( seed + q, k );
std::uint64_t h = ( seed + q ) * k;
std::uint32_t w = (std::uint32_t)h;

h ^= n;
Expand Down Expand Up @@ -319,12 +319,12 @@ inline std::uint32_t mulxp1_hash32( unsigned char const * p, std::size_t n, std:
return (std::uint32_t)h ^ (std::uint32_t)(h >> 32);
}

inline std::uint32_t mulxp3_hash32( unsigned char const * p, std::size_t n, std::uint32_t seed )
inline std::uint32_t mulxp3_hash32( unsigned char const * p, std::size_t n, std::uint64_t seed )
{
std::uint32_t const q = 0x9e3779b9U;
std::uint32_t const k = q * q;

std::uint64_t h = mul32( seed + q, k );
std::uint64_t h = ( seed + q ) * k;
std::uint32_t w = (std::uint32_t)h;

h ^= n;
Expand Down

0 comments on commit 4279b22

Please sign in to comment.