From: Mikko Rasa Date: Sat, 3 Apr 2021 15:44:36 +0000 (+0300) Subject: Add folding functions for hashes X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=229f0438383b1ab7d0de0f9ea9a9a2912363bdbc;p=libs%2Fcore.git Add folding functions for hashes --- 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