From d97741b6a9da294c37f923aea6ebe9ef0c9e971e Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Thu, 17 Aug 2017 20:45:46 +0200 Subject: [PATCH] Update to use FNVHASH for internal hash calculation for object. (Not for memory layout). --- m-core.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/m-core.h b/m-core.h index fa9d8098..72f0dfd3 100644 --- a/m-core.h +++ b/m-core.h @@ -659,17 +659,15 @@ #elif defined(M_USE_BPHASH) #define M_HASH_INIT 0UL #define M_HASH_CALC(h1,h2) (((h1) << 7) ^ (h2)) -#elif defined(M_USE_FNVHASH) +#else +//FNVHASH #define M_HASH_INIT 0UL #define M_HASH_CALC(h1,h2) (((h1) * 0x811C9DC5UL) ^ (h2)) -#else -#define M_HASH_INIT 0UL -#define M_HASH_CALC(h1,h2) (((h1) * 31421) + (h2) + 6927) #endif #define M_HASH_DECL(hash) size_t hash = M_HASH_INIT ^ M_HASH_SEED #define M_HASH_UP(hash,h) do { hash = M_HASH_CALC(hash, (h)); } while (0) -#define M_HASH_FINAL(hash) (hash) +#define M_HASH_FINAL(hash) ( (hash) >> (sizeof(size_t)*CHAR_BIT/2) | (hash) ) /* Safe, efficient, and portable Rotate: It should be recognized by any compiler and generate a single roll instruction */