summaryrefslogtreecommitdiffhomepage
path: root/include/stc/cmap.h
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-08-17 10:36:26 +0200
committerTyge Løvset <[email protected]>2022-08-17 10:36:26 +0200
commit3b41222609e3f54d4ada55e08f1fc9a7446189f1 (patch)
treed9a0b56f1b48415fd6aaf3c86003debe4ae814c1 /include/stc/cmap.h
parent0681b8a9af2ac6041e937bc8ca7bc8d496dcc0d4 (diff)
downloadSTC-modified-3b41222609e3f54d4ada55e08f1fc9a7446189f1.tar.gz
STC-modified-3b41222609e3f54d4ada55e08f1fc9a7446189f1.zip
Fix cmap_X_end() function.
Diffstat (limited to 'include/stc/cmap.h')
-rw-r--r--include/stc/cmap.h28
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)