Simplify expansion of mt and iv a bit

This commit is contained in:
dearblue
2024-03-14 22:12:35 +09:00
parent 2b597c596c
commit 227ebb9daa
2 changed files with 2 additions and 7 deletions
+1 -4
View File
@@ -67,12 +67,9 @@ static void
mt_rehash(mrb_state *mrb, mt_tbl *t)
{
int old_alloc = t->alloc;
int new_alloc = old_alloc+8;
int new_alloc = old_alloc > 0 ? old_alloc << 1 : 8;
union mt_ptr *old_ptr = t->ptr;
khash_power2(new_alloc);
if (old_alloc == new_alloc) return;
t->ptr = (union mt_ptr*)mrb_calloc(mrb, sizeof(union mt_ptr)+sizeof(mrb_sym), new_alloc);
t->alloc = new_alloc;
t->size = 0;
+1 -3
View File
@@ -43,11 +43,9 @@ static void
iv_rehash(mrb_state *mrb, iv_tbl *t)
{
int old_alloc = t->alloc;
int new_alloc = old_alloc+4;
int new_alloc = old_alloc > 0 ? old_alloc << 1 : 4;
mrb_value *old_ptr = t->ptr;
khash_power2(new_alloc);
t->ptr = (mrb_value*)mrb_calloc(mrb, sizeof(mrb_value)+sizeof(mrb_sym), new_alloc);
t->size = 0;
t->alloc = new_alloc;