From 74f0fd91e953c97b92eda6f10233b536309fdc53 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sun, 3 Aug 2025 21:21:15 +0900 Subject: [PATCH] khash: rename KHASH_SMALL_THRESHOLD to KHASH_SMALL_LIMIT Rename KHASH_SMALL_THRESHOLD to KHASH_SMALL_LIMIT for brevity and clarity. The shorter name is more concise while maintaining clear meaning as the upper bound for small table optimization. Co-authored-by: Claude --- include/mruby/khash.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/mruby/khash.h b/include/mruby/khash.h index 30792f641..bfad298e2 100644 --- a/include/mruby/khash.h +++ b/include/mruby/khash.h @@ -24,7 +24,7 @@ typedef khint_t khiter_t; # define KHASH_INITIAL_SIZE 8 #endif #define KHASH_MIN_SIZE 8 -#define KHASH_SMALL_THRESHOLD 4 +#define KHASH_SMALL_LIMIT 4 #define KH_UPPER_BOUND(x) ((x) - ((x)>>3)) /* 87.5% load factor */ @@ -197,7 +197,7 @@ static const uint8_t __m_either[] = {0x03, 0x0c, 0x30, 0xc0}; return pos; \ } \ /* Check if we need to convert to hash table */ \ - if (h->size >= KHASH_SMALL_THRESHOLD) { \ + if (h->size >= KHASH_SMALL_LIMIT) { \ /* Convert from small table to hash table */ \ kh__rebuild_##name(mrb, h, KHASH_MIN_SIZE); \ /* Now add the new key using regular hash table */ \ @@ -323,10 +323,10 @@ static const uint8_t __m_either[] = {0x03, 0x0c, 0x30, 0xc0}; return h2; \ } \ void kh_init_data_##name(mrb_state *mrb, kh_##name##_t *h, khint_t size) { \ - if (size <= KHASH_SMALL_THRESHOLD) { \ + if (size <= KHASH_SMALL_LIMIT) { \ /* Start as small table */ \ h->n_buckets = 0; /* Small table marker */ \ - h->data = mrb_malloc(mrb, kh__kv_size_##name(KHASH_SMALL_THRESHOLD)); \ + h->data = mrb_malloc(mrb, kh__kv_size_##name(KHASH_SMALL_LIMIT)); \ h->size = 0; \ } \ else { \ @@ -356,7 +356,7 @@ static const uint8_t __m_either[] = {0x03, 0x0c, 0x30, 0xc0}; } \ else if (src->n_buckets == 0) { \ /* Small table case */ \ - size_t data_size = kh__kv_size_##name(KHASH_SMALL_THRESHOLD); \ + size_t data_size = kh__kv_size_##name(KHASH_SMALL_LIMIT); \ dst->data = mrb_realloc(mrb, dst->data, data_size); \ dst->size = src->size; \ dst->n_buckets = 0; \