summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-08-26 22:29:26 +0200
committerTyge Løvset <[email protected]>2020-08-26 22:29:26 +0200
commit1ce1c7f77957f684aa0676478709637345f81a22 (patch)
tree60ea79bbbb092be75e95ed30defa50ca85d3d5ac
parent03f61e592c984f52536097af3684568fc171d722 (diff)
downloadSTC-modified-1ce1c7f77957f684aa0676478709637345f81a22.tar.gz
STC-modified-1ce1c7f77957f684aa0676478709637345f81a22.zip
Minor optimizations.
-rw-r--r--stc/cmap.h7
1 files changed, 3 insertions, 4 deletions
diff --git a/stc/cmap.h b/stc/cmap.h
index 6be45863..1840eda6 100644
--- a/stc/cmap.h
+++ b/stc/cmap.h
@@ -360,9 +360,8 @@ STC_API bool \
ctype##_##tag##_erase(ctype##_##tag* self, ctype##_##tag##_rawkey_t rawKey) { \
if (self->size == 0) \
return false; \
- size_t cap = self->bucket_count; \
- if (self->size < cap * self->shrink_limit_factor && cap * sizeof(ctype##_##tag##_entry_t) > 1024) \
- ctype##_##tag##_reserve(self, self->size * 6 / 5); \
+ if (self->size < self->bucket_count * self->shrink_limit_factor && self->bucket_count * sizeof(ctype##_##tag##_entry_t) > 1024) \
+ ctype##_##tag##_reserve(self, (size_t) (self->size * 1.2f / self->max_load_factor)); \
uint32_t hx; \
size_t i = ctype##_##tag##_bucket(self, &rawKey, &hx); \
return ctype##_##tag##_erase_entry(self, self->table + i); \
@@ -371,7 +370,7 @@ ctype##_##tag##_erase(ctype##_##tag* self, ctype##_##tag##_rawkey_t rawKey) { \
STC_API ctype##_##tag##_iter_t \
ctype##_##tag##_begin(ctype##_##tag* map) { \
ctype##_##tag##_iter_t it = {map->table, map->table + map->bucket_count, map->_hashx}; \
- while (it.item != it.end && *it._hx == 0) ++it.item, ++it._hx; \
+ if (it._hx) while (*it._hx == 0) ++it.item, ++it._hx; \
return it; \
} \
\