diff options
author | Fabian Jahr <fjahr@protonmail.com> | 2023-12-12 18:37:48 +0100 |
---|---|---|
committer | Fabian Jahr <fjahr@protonmail.com> | 2024-01-05 17:12:38 +0100 |
commit | 60446285436da62adef1c0a9b11c3336d82b4d89 (patch) | |
tree | 8e2018fdcfb440717ba806f6e60dcb5c7a3d821b /src/hash.cpp | |
parent | 08e6aaabef6c569ba634c86d396f0a840002a8d2 (diff) |
crypto, hash: replace custom rotl32 with std::rotl
Diffstat (limited to 'src/hash.cpp')
-rw-r--r-- | src/hash.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/hash.cpp b/src/hash.cpp index 1ece8c5a79..78a969ecd3 100644 --- a/src/hash.cpp +++ b/src/hash.cpp @@ -7,13 +7,9 @@ #include <crypto/common.h> #include <crypto/hmac_sha512.h> +#include <bit> #include <string> -inline uint32_t ROTL32(uint32_t x, int8_t r) -{ - return (x << r) | (x >> (32 - r)); -} - unsigned int MurmurHash3(unsigned int nHashSeed, Span<const unsigned char> vDataToHash) { // The following is MurmurHash3 (x86_32), see https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp @@ -31,11 +27,11 @@ unsigned int MurmurHash3(unsigned int nHashSeed, Span<const unsigned char> vData uint32_t k1 = ReadLE32(blocks + i*4); k1 *= c1; - k1 = ROTL32(k1, 15); + k1 = std::rotl(k1, 15); k1 *= c2; h1 ^= k1; - h1 = ROTL32(h1, 13); + h1 = std::rotl(h1, 13); h1 = h1 * 5 + 0xe6546b64; } @@ -55,7 +51,7 @@ unsigned int MurmurHash3(unsigned int nHashSeed, Span<const unsigned char> vData case 1: k1 ^= tail[0]; k1 *= c1; - k1 = ROTL32(k1, 15); + k1 = std::rotl(k1, 15); k1 *= c2; h1 ^= k1; } |