From 229f0438383b1ab7d0de0f9ea9a9a2912363bdbc Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 3 Apr 2021 18:44:36 +0300 Subject: [PATCH] Add folding functions for hashes --- source/core/hash.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/core/hash.h b/source/core/hash.h index 75aba09..d696cae 100644 --- a/source/core/hash.h +++ b/source/core/hash.h @@ -31,6 +31,12 @@ Convenience function to compute a 64-bit hash of a string. inline UInt64 hash64(const std::string &s, unsigned b = 64) { return hash64(s.data(), s.size(), b); } +inline UInt32 fold32(UInt64 hash) +{ return hash^(hash>>32); } + +inline UInt16 fold16(UInt64 hash) +{ return hash^(hash>>16)^(hash>>32)^(hash>>48); } + } // namespace Msp #endif -- 2.43.0