From d314fa40bcfc3a7d5e4dfc8136aebff309db8667 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Mon, 4 Oct 2021 08:08:24 +0200 Subject: Removed c_apply_pair_n() macro. Small improvements in examples. --- include/stc/ccommon.h | 6 ------ include/stc/cmap.h | 8 +++----- 2 files changed, 3 insertions(+), 11 deletions(-) (limited to 'include/stc') 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}; } -- cgit v1.2.3