75[[nodiscard]]
inline uint32_t
xxhash_impl(
const uint8_t* p,
size_t size)
77 constexpr uint32_t MASK32 = MASK8 * 0x01010101U;
79 const uint8_t*
const bEnd = p + size;
82 if (size >= 16) [[unlikely]] {
83 const uint8_t*
const limit = bEnd - 16;
92 uint32_t r1 = (read32<ALIGNED>(p + 0) & MASK32) *
PRIME32_2;
93 uint32_t r2 = (read32<ALIGNED>(p + 4) & MASK32) *
PRIME32_2;
94 uint32_t r3 = (read32<ALIGNED>(p + 8) & MASK32) *
PRIME32_2;
95 uint32_t r4 = (read32<ALIGNED>(p + 12) & MASK32) *
PRIME32_2;
101 }
while (p <= limit);
103 h32 = std::rotl(v1, 1) + std::rotl(v2, 7) + std::rotl(v3, 12) + std::rotl(
v4, 18);
108 h32 += uint32_t(size);
110 while ((p + 4) <= bEnd) {
111 uint32_t r = (read32<ALIGNED>(p) & MASK32) *
PRIME32_3;
112 h32 = std::rotl(h32 + r, 17) *
PRIME32_4;
118 h32 = std::rotl(h32 + r, 11) *
PRIME32_1;
124 return h32 ^ (h32 >> 16);
127template<u
int8_t MASK8> [[nodiscard]]
inline uint32_t
xxhash_impl(std::string_view key)
129 const auto* data = std::bit_cast<const uint8_t*>(key.data());
130 auto size = key.size();
131 if (std::bit_cast<intptr_t>(data) & 3) {
132 return xxhash_impl<false, MASK8>(data, size);
135 return xxhash_impl<true, MASK8>(data, size);