From b70ed765ff6cf51aff20714e3ec4415b06898059 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Thu, 28 Mar 2024 00:02:43 +0100 Subject: Random work --- deimos/core/hash.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'deimos/core/hash.h') diff --git a/deimos/core/hash.h b/deimos/core/hash.h index f1e8958..6ad30b0 100644 --- a/deimos/core/hash.h +++ b/deimos/core/hash.h @@ -5,7 +5,7 @@ namespace deimos { -constexpr uint64 MurmurHash3_GetBlock64(const char* key, uint64 block) +constexpr uint64 MurmurHash3_GetBlock64(const byte* key, uint64 block) { // NOLINTBEGIN key += block * 8; @@ -41,12 +41,11 @@ constexpr uint64 MurmurHash3_Fmix64(uint64 k) return k; } -constexpr uint128 MurmurHash3_x64_128(const char* key) +constexpr uint128 MurmurHash3_x64_128(const byte* key, uint64 len) { if consteval { return { 12, 12 }; } // NOLINTBEGIN - const uint64 len = __builtin_strlen(key); const uint64 nblocks = len / 16; const int64 seed = 0; @@ -73,7 +72,7 @@ constexpr uint128 MurmurHash3_x64_128(const char* key) //---------- // tail - const char* tail = key + nblocks * 16; + const byte* tail = key + nblocks * 16; uint64 k1 = 0; uint64 k2 = 0; @@ -118,5 +117,10 @@ constexpr uint128 MurmurHash3_x64_128(const char* key) return uint128{h1, h2}; } +constexpr uint128 MurmurHash3_x64_128(gsl::czstring str) +{ + return MurmurHash3_x64_128(BitCast(str), __builtin_strlen(str)); +} + } // namespace deimos -- cgit