summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-04-24 08:52:15 +0200
committerTyge Løvset <[email protected]>2023-04-24 08:52:15 +0200
commit38aab1d6ae8f929084ae6c67256a87760cc07705 (patch)
tree621fbe64cdb6432d945727ca100fd97b3f53aad5
parent3139f550e2af86003e08f0795e395690c120d63e (diff)
downloadSTC-modified-38aab1d6ae8f929084ae6c67256a87760cc07705.tar.gz
STC-modified-38aab1d6ae8f929084ae6c67256a87760cc07705.zip
Fixed another cmap issue
-rw-r--r--include/stc/ccommon.h2
-rw-r--r--include/stc/cmap.h4
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);