From 38aab1d6ae8f929084ae6c67256a87760cc07705 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Mon, 24 Apr 2023 08:52:15 +0200 Subject: Fixed another cmap issue --- include/stc/ccommon.h | 2 +- include/stc/cmap.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index bac25fb1..121bc566 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -147,7 +147,7 @@ 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 | (*x << 15), n = (uint64_t)len >> 3; + uint64_t h = (*x << 15) - *x, n = (uint64_t)len >> 3; len &= 7; while (n--) { memcpy(&u8, x, 8), x += 8; diff --git a/include/stc/cmap.h b/include/stc/cmap.h index 34a9ec79..533e8a16 100644 --- a/include/stc/cmap.h +++ b/include/stc/cmap.h @@ -380,8 +380,8 @@ _cx_memb(_bucket_)(const _cx_self* self, const _cx_keyraw* rkeyptr) { STC_DEF _cx_result _cx_memb(_insert_entry_)(_cx_self* self, _cx_keyraw rkey) { _cx_result res = {NULL}; - if (self->size + 2 > (intptr_t)((float)self->bucket_count * (i_max_load_factor))) - if (!_cx_memb(_reserve)(self, (intptr_t)(self->size*3/2))) + if (self->size >= (intptr_t)((float)self->bucket_count * (i_max_load_factor))) + if (!_cx_memb(_reserve)(self, (intptr_t)(self->size*3/2 + 2))) return res; chash_bucket b = _cx_memb(_bucket_)(self, &rkey); -- cgit v1.2.3