summaryrefslogtreecommitdiffhomepage
path: root/include/stc/ccommon.h
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-04-14 16:50:52 +0200
committerTyge Løvset <[email protected]>2023-04-14 16:50:52 +0200
commit462adebf55c77697fbb379a62941c00b876c3f6a (patch)
tree737a2c5cdc6bd69f6e739ae666d8e8a44e62b33c /include/stc/ccommon.h
parent0516aa3ae823ed9a22b2c5f776948c8447c32c31 (diff)
downloadSTC-modified-462adebf55c77697fbb379a62941c00b876c3f6a.tar.gz
STC-modified-462adebf55c77697fbb379a62941c00b876c3f6a.zip
tuning of hash function. Adjusted benchmark balance.
Diffstat (limited to 'include/stc/ccommon.h')
-rw-r--r--include/stc/ccommon.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index d5508807..bc12e642 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -147,14 +147,14 @@ STC_INLINE uint64_t cfasthash(const void* key, intptr_t len) {
case 0: return 1;
}
const uint8_t *x = (const uint8_t*)key;
- uint64_t h = *x, n = (uint64_t)len >> 3;
+ uint64_t h = 0xcbf29ce484222325 + *x*0x811c9dc5UL, n = (uint64_t)len >> 3;
len &= 7;
while (n--) {
memcpy(&u8, x, 8), x += 8;
- h += u8*0xc6a4a7935bd1e99d;
+ h = (h ^ u8)*0x01000193UL;
}
- while (len--) h = (h << 10) - h - *x++;
- return c_ROTL(h, 26) ^ h;
+ while (len--) h = (h ^ *x++)*0x01000193UL;
+ return h;
}
STC_INLINE uint64_t cstrhash(const char *str)