diff --git a/treetrie.c b/treetrie.c index d545a37..d9edd63 100644 --- a/treetrie.c +++ b/treetrie.c @@ -10,31 +10,31 @@ typedef uint32_t tt_hash_t; -/* /\* Customized special-purpose fasthash variation *\/ */ -/* #define mix(h) ({ \ */ -/* (h) ^= (h) >> 23; \ */ -/* (h) *= 0x2127599bf4325c37ULL; \ */ -/* (h) ^= (h) >> 47; }) */ -/* static inline uint64_t fasthash_4_ints(uint32_t v1, uint32_t v2, uint32_t v3, uint32_t v4) { */ -/* const uint64_t m = 0x880355f21e6d1965ULL; */ -/* uint64_t h = (16 * m); */ -/* uint64_t v; */ -/* v = (((uint64_t) v2) << 32) | v1; */ -/* h ^= mix(v); */ -/* h *= m; */ -/* v = (((uint64_t) v4) << 32) | v3; */ -/* h ^= mix(v); */ -/* h *= m; */ -/* return mix(h); */ -/* } */ +/* Customized special-purpose fasthash variation */ +#define mix(h) ({ \ + (h) ^= (h) >> 23; \ + (h) *= 0x2127599bf4325c37ULL; \ + (h) ^= (h) >> 47; }) +static inline uint64_t fasthash_4_ints(uint32_t v1, uint32_t v2, uint32_t v3, uint32_t v4) { + const uint64_t m = 0x880355f21e6d1965ULL; + uint64_t h = (16 * m); + uint64_t v; + v = (((uint64_t) v2) << 32) | v1; + h ^= mix(v); + h *= m; + v = (((uint64_t) v4) << 32) | v3; + h ^= mix(v); + h *= m; + return mix(h); +} static inline tt_hash_t hash(uint32_t tag, uint32_t index, tt_node_ptr_t a, tt_node_ptr_t b) { - /* uint64_t x = fasthash_4_ints(tag, index, a, b); */ - /* return x - (x >> 32); */ + uint64_t x = fasthash_4_ints(tag, index, a, b); + return x - (x >> 32); /* uint32_t keyblock[4] = { tag, */ /* index, */ @@ -42,19 +42,6 @@ static inline tt_hash_t hash(uint32_t tag, /* b }; */ /* assert(sizeof(keyblock) == 4 * sizeof(uint32_t)); */ /* return (tt_hash_t) fasthash32(keyblock, sizeof(keyblock), 0); */ - - /* uint64_t x = tag; */ - /* x = (x << 8) ^ index; */ - /* x = (x << 8) ^ a; */ - /* x = (x << 8) ^ b; */ - /* return x - (x >> 32); */ - - uint64_t x = index * 11; - x *= 11; - x ^= a; - x *= 11; - x ^= b * tag; - return x - (x >> 32); } static inline tt_hash_t tt_hash_node(tt_arena_t *a, tt_node_ptr_t p) {