mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #6206 from dearblue/table-expansion
Simplify expansion of mt and iv a bit
This commit is contained in:
+1
-4
@@ -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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user