khash.h: refactor rebuild to handle linear tables

This change allows for handling small tables as linear-search arrays,
improving performance for hashes with few elements.

Co-authored-by: Gemini <gemini@google.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-08-19 09:42:17 +09:00
parent d42326ce80
commit ac3c160c3a
+1 -2
View File
@@ -167,9 +167,8 @@ static const uint8_t __m_either[] = {0x03, 0x0c, 0x30, 0xc0};
static inline void kh__rebuild_##name(mrb_state *mrb, kh_##name##_t *h, khint_t new_n_buckets) { \
kh_##name##_t hh; \
hh.data = NULL; \
hh.n_buckets = new_n_buckets; \
hh.size = 0; \
kh__alloc_##name(mrb, &hh); \
kh_init_data_##name(mrb, &hh, new_n_buckets); \
/* Rehash from old 'h' to 'hh' */ \
khkey_t *old_keys = kh_keys_##name(h); \
khval_t *old_vals = kh_vals_##name(h); \