summaryrefslogtreecommitdiffhomepage
path: root/include/stc
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-10-04 08:08:24 +0200
committerTyge Løvset <[email protected]>2021-10-04 08:08:24 +0200
commitd314fa40bcfc3a7d5e4dfc8136aebff309db8667 (patch)
tree0e10755092f5754d9bd43374750b413dec332798 /include/stc
parent882e173a2cc9a09c3a96a330f981daa11e34e0d0 (diff)
downloadSTC-modified-d314fa40bcfc3a7d5e4dfc8136aebff309db8667.tar.gz
STC-modified-d314fa40bcfc3a7d5e4dfc8136aebff309db8667.zip
Removed c_apply_pair_n() macro. Small improvements in examples.
Diffstat (limited to 'include/stc')
-rw-r--r--include/stc/ccommon.h6
-rw-r--r--include/stc/cmap.h8
2 files changed, 3 insertions, 11 deletions
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index af56f43a..c9ca7ad0 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -168,17 +168,11 @@ STC_API uint64_t c_default_hash(const void *key, size_t len);
for (size_t _c_i = 0; _c_i < c_arraylen(_c_arr); ++_c_i) \
CX##_##method(_c_cx, _c_arr[_c_i].first, _c_arr[_c_i].second); \
} while (0)
-
#define c_apply_n(CX, method, cx, arr, n) do { \
CX* _c_cx = cx; \
for (const CX##_rawvalue_t *_c_i = arr, *_c_end = _c_i+(n); _c_i != _c_end; ++_c_i) \
CX##_##method(_c_cx, *_c_i); \
} while (0)
-#define c_apply_pair_n(CX, method, cx, arr, n) do { \
- CX* _c_cx = cx; \
- for (const CX##_rawvalue_t *_c_i = arr, *_c_end = _c_i+(n); _c_i != _c_end; ++_c_i) \
- CX##_##method(_c_cx, _c_i->first, _c_i->second); \
-} while (0)
#define c_del(CX, ...) do { \
CX* _c_arr[] = {__VA_ARGS__}; \
diff --git a/include/stc/cmap.h b/include/stc/cmap.h
index 1cb61d00..203f0e79 100644
--- a/include/stc/cmap.h
+++ b/include/stc/cmap.h
@@ -162,11 +162,9 @@ cx_memb(_insert)(Self* self, i_key _key cx_MAP_ONLY(, i_val _mapped)) {
STC_INLINE cx_iter_t
cx_memb(_find)(const Self* self, i_keyraw rkey) {
- cx_size_t idx = self->bucket_count;
- if (self->size) {
- chash_bucket_t b = cx_memb(_bucket_)(self, &rkey);
- if (self->_hashx[b.idx]) idx = b.idx;
- }
+ cx_size_t idx;
+ if (!(self->size && self->_hashx[idx = cx_memb(_bucket_)(self, &rkey).idx]))
+ idx = self->bucket_count;
return c_make(cx_iter_t){self->table+idx, self->_hashx+idx};
}