mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Prevented resizing just created hashes in specific size ranges
This commit is contained in:
+2
-1
@@ -145,7 +145,8 @@ mrb_hash_new_capa(mrb_state *mrb, mrb_int capa)
|
||||
struct RHash *h;
|
||||
|
||||
h = (struct RHash*)mrb_obj_alloc(mrb, MRB_TT_HASH, mrb->hash_class);
|
||||
h->ht = kh_init_size(ht, mrb, capa);
|
||||
/* khash needs 1/4 empty space so it is not resized immediately */
|
||||
h->ht = kh_init_size(ht, mrb, capa*4/3);
|
||||
h->iv = 0;
|
||||
return mrb_obj_value(h);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user