diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-02-27 07:55:57 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-02-27 12:37:23 +0100 |
commit | 942245397e6c2f3e6642b29a3be2cae999aab16d (patch) | |
tree | cd0e90d0ef5342f0a677f188475b553fa55c8ac2 | |
parent | f60c3734e38408b97e10e29a6c1d8780770d5b79 (diff) |
compat: replace int hash
-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; |