Commit 13587257 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #3764 from christopheraue/new_hash_perf

Improved speed of creating new hash tables
parents 1b9c4855 ec7475d8
......@@ -145,10 +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(ht, mrb);
if (capa > 0) {
kh_resize(ht, mrb, h->ht, 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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment