diff options
| -rw-r--r-- | include/stc/cmap.h | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/include/stc/cmap.h b/include/stc/cmap.h index 58774fb2..d62dbe64 100644 --- a/include/stc/cmap.h +++ b/include/stc/cmap.h @@ -188,10 +188,19 @@ _cx_memb(_push)(_cx_self* self, _cx_value _val) { return _res; } +STC_INLINE _cx_iter +_cx_memb(_begin)(const _cx_self* self) { + _cx_iter it = {self->table, self->table+self->bucket_count, self->_hashx}; + if (it._hx) + while (*it._hx == 0) + ++it.ref, ++it._hx; + if (it.ref == it.end) it.ref = NULL; + return it; +} STC_INLINE _cx_iter _cx_memb(_end)(const _cx_self* self) - { return c_make(_cx_iter){NULL}; } + { return c_make(_cx_iter){NULL, self->table + self->bucket_count}; } STC_INLINE void _cx_memb(_next)(_cx_iter* it) { @@ -208,9 +217,10 @@ _cx_memb(_advance)(_cx_iter it, size_t n) { STC_INLINE _cx_iter _cx_memb(_find)(const _cx_self* self, _cx_rawkey rkey) { i_size idx; - if (!(self->size && self->_hashx[idx = _cx_memb(_bucket_)(self, &rkey).idx])) - return _cx_memb(_end)(self); - return c_make(_cx_iter){self->table+idx, self->table+self->bucket_count, self->_hashx+idx}; + _cx_value* end = self->table + self->bucket_count; + if (self->size && self->_hashx[idx = _cx_memb(_bucket_)(self, &rkey).idx]) + return c_make(_cx_iter){self->table + idx, end, self->_hashx + idx}; + return c_make(_cx_iter){NULL, end}; } STC_INLINE const _cx_value* @@ -225,16 +235,6 @@ STC_INLINE _cx_value* _cx_memb(_get_mut)(_cx_self* self, _cx_rawkey rkey) { return (_cx_value*)_cx_memb(_get)(self, rkey); } -STC_INLINE _cx_iter -_cx_memb(_begin)(const _cx_self* self) { - _cx_iter it = {self->table, self->table+self->bucket_count, self->_hashx}; - if (it._hx) - while (*it._hx == 0) - ++it.ref, ++it._hx; - if (it.ref == it.end) it.ref = NULL; - return it; -} - STC_INLINE size_t _cx_memb(_erase)(_cx_self* self, _cx_rawkey rkey) { if (self->size == 0) |
