From 53d2199dff3dfd3a80c56877c1fa8c26c8c16124 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Wed, 4 Nov 2020 14:32:50 +0100 Subject: Larger constant Phi in hash16. --- stc/ccommon.h | 2 +- stc/cmap.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stc/ccommon.h b/stc/ccommon.h index 75567256..3cda038d 100644 --- a/stc/ccommon.h +++ b/stc/ccommon.h @@ -76,7 +76,7 @@ #endif #define c_swap(T, x, y) do { T __t = x; x = y; y = __t; } while (0) #define c_no_compare(x, y) (0) -#define c_mem_equals(x, y) (memcmp(x, y, sizeof(*(y))) == 0) +#define c_mem_equals(x, y) (memcmp(x, y, sizeof *(x)) == 0) #define c_default_equals(x, y) (*(x) == *(y)) #define c_default_less(x, y) (*(x) < *(y)) #define c_less_compare(less, x, y) (less(y, x) - less(x, y)) diff --git a/stc/cmap.h b/stc/cmap.h index 4197b169..e9a4bc72 100644 --- a/stc/cmap.h +++ b/stc/cmap.h @@ -445,8 +445,8 @@ typedef struct {size_t idx; uint32_t hx;} cmap_bucket_t, cset_bucket_t; STC_DEF uint32_t c_default_hash16(const void *data, size_t len) { const volatile uint16_t *key = (const uint16_t *) data; - uint64_t x = *key++ * 0xc613fc15u; - while (len -= 2) x = (*key++ + x) * 2654435769ull; + uint64_t x = *key++ * 11400714819323198485llu; + while (len -= 2) x = (*key++ + x) * 11400714819323198485llu; return (uint32_t) x; } STC_DEF uint32_t c_default_hash32(const void* data, size_t len) { -- cgit v1.2.3