summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-06-10 16:04:22 +0200
committerTyge Løvset <[email protected]>2022-06-10 16:04:22 +0200
commitd0ce3effae99478bd593011795b4184d4fddaed4 (patch)
tree33920f2d3927eabc103cd4f4c6d2e5e6c676223f /include
parentff29ab1ec7fd199fd0e9d0bd0884c1905dd0c1c1 (diff)
downloadSTC-modified-d0ce3effae99478bd593011795b4184d4fddaed4.tar.gz
STC-modified-d0ce3effae99478bd593011795b4184d4fddaed4.zip
Small simplifications in cmap.h
Diffstat (limited to 'include')
-rw-r--r--include/stc/cmap.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/stc/cmap.h b/include/stc/cmap.h
index e193a8d0..9725de70 100644
--- a/include/stc/cmap.h
+++ b/include/stc/cmap.h
@@ -106,7 +106,7 @@ STC_INLINE bool _cx_memb(_empty)(_cx_self m) { return m.size == 0; }
STC_INLINE size_t _cx_memb(_size)(_cx_self m) { return m.size; }
STC_INLINE size_t _cx_memb(_bucket_count)(_cx_self map) { return map.bucket_count; }
STC_INLINE size_t _cx_memb(_capacity)(_cx_self map)
- { return map.bucket_count ? (size_t)((map.bucket_count - 2)*map.max_load_factor) : 0u; }
+ { return (size_t)(map.bucket_count*map.max_load_factor); }
STC_INLINE void _cx_memb(_swap)(_cx_self *map1, _cx_self *map2) {c_swap(_cx_self, *map1, *map2); }
STC_INLINE bool _cx_memb(_contains)(const _cx_self* self, _cx_rawkey rkey)
{ return self->size && self->_hashx[_cx_memb(_bucket_)(self, &rkey).idx]; }
@@ -334,8 +334,8 @@ _cx_memb(_bucket_)(const _cx_self* self, const _cx_rawkey* rkeyptr) {
STC_DEF _cx_result
_cx_memb(_insert_entry_)(_cx_self* self, _cx_rawkey rkey) {
bool nomem = false;
- if (self->size + 1 >= (i_size)(self->bucket_count*self->max_load_factor))
- nomem = !_cx_memb(_reserve)(self, ((size_t)self->size*3 >> 1) + 4);
+ if (self->size >= (i_size)(self->bucket_count*self->max_load_factor))
+ nomem = !_cx_memb(_reserve)(self, self->size*3/2);
chash_bucket_t b = _cx_memb(_bucket_)(self, &rkey);
_cx_result res = {&self->table[b.idx], !self->_hashx[b.idx], nomem};
if (res.inserted) {