khash.h: inline kh_alloc_small function used only once

Removed kh_alloc_small_##name() function and inlined its body into the
single call site in kh_init_data_##name(). This eliminates unnecessary
function call overhead and reduces code complexity.

The function was only 2 lines and called once, making it an ideal
candidate for inlining.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-08-03 06:32:35 +09:00
parent 22a6debf40
commit da09bae640
+2 -7
View File
@@ -181,10 +181,6 @@ static const uint8_t __m_either[] = {0x03, 0x0c, 0x30, 0xc0};
if (ret) *ret = 1; /* New key */ \
return h->size - 1; \
} \
static inline void kh_alloc_small_##name(mrb_state *mrb, kh_##name##_t *h) { \
h->data = mrb_malloc(mrb, kh_kv_size_##name(KHASH_SMALL_THRESHOLD));\
h->size = 0; \
} \
void kh_alloc_##name(mrb_state *mrb, kh_##name##_t *h) \
{ \
khint_t sz = h->n_buckets; \
@@ -337,9 +333,8 @@ static const uint8_t __m_either[] = {0x03, 0x0c, 0x30, 0xc0};
if (size <= KHASH_SMALL_THRESHOLD) { \
/* Start as small table */ \
h->n_buckets = 0; /* Small table marker */ \
if (kh_alloc_small_##name(mrb, h)) { \
mrb_raise_nomemory(mrb); \
} \
h->data = mrb_malloc(mrb, kh_kv_size_##name(KHASH_SMALL_THRESHOLD)); \
h->size = 0; \
} \
else { \
/* Start as regular hash table */ \