diff options
-rw-r--r-- | compat/int-hash.hpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/compat/int-hash.hpp b/compat/int-hash.hpp index 43b92605..36f0c8b8 100644 --- a/compat/int-hash.hpp +++ b/compat/int-hash.hpp @@ -1,5 +1,6 @@ #pragma once #include <cstddef> +#include <bit> namespace floormat { @@ -16,12 +17,12 @@ constexpr inline std::size_t int_hash(std::size_t x) noexcept } else if constexpr(sizeof(std::size_t) == 8) { - // splitmix64 by George Marsaglia - x ^= x >> 30; - x *= 0xbf58476d1ce4e5b9U; - x ^= x >> 27; - x *= 0x94d049bb133111ebU; - x ^= x >> 31; + // NASAM by Pelle Evensen <https://mostlymangling.blogspot.com/2020/01/nasam-not-another-strange-acronym-mixer.html> + x ^= std::rotr(x, 25) ^ std::rotr(x, 47); + x *= 0x9E6C63D0676A9A99UL; + x ^= x >> 23 ^ x >> 51; + x *= 0x9E6D62D06F6A9A9BUL; + x ^= x >> 23 ^ x >> 51; } return x; |