From 165e10b6cf73f723c2f6af676b70aeb2d8cf85c9 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 11 Dec 2015 02:38:20 +0000 Subject: compile.c: rehash cdhash * compile.c (iseq_compile_each, ibf_load_object_hash): rehash case-dispatch hash to reduce collisions. http://d.hatena.ne.jp/ku-ma-me/20151210 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ compile.c | 2 ++ hash.c | 2 +- internal.h | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f199d9d414..f800dd7633 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Dec 11 11:38:14 2015 Nobuyoshi Nakada + + * compile.c (iseq_compile_each, ibf_load_object_hash): rehash + case-dispatch hash to reduce collisions. + http://d.hatena.ne.jp/ku-ma-me/20151210 + Fri Dec 11 03:44:43 2015 NARUSE, Yui * object.c (rb_inspect): dump inspected result with rb_str_escape() diff --git a/compile.c b/compile.c index 44e0d81aec..79cfb145ef 100644 --- a/compile.c +++ b/compile.c @@ -1640,6 +1640,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor) data.len = len; rb_hash_foreach(map, cdhash_set_label_i, (VALUE)&data); + rb_hash_rehash(map); freeze_hide_obj(map); generated_iseq[code_index + 1 + j] = map; break; @@ -7736,6 +7737,7 @@ ibf_load_object_hash(const struct ibf_load *load, const struct ibf_object_header VALUE val = ibf_load_object(load, hash->keyval[i*2+1]); rb_hash_aset(obj, key, val); } + rb_hash_rehash(obj); if (header->internal) rb_obj_hide(obj); if (header->frozen) rb_obj_freeze(obj); diff --git a/hash.c b/hash.c index 1fd9d12e15..52479c0ac2 100644 --- a/hash.c +++ b/hash.c @@ -734,7 +734,7 @@ rb_hash_rehash_i(VALUE key, VALUE value, VALUE arg) * h[a] #=> 100 */ -static VALUE +VALUE rb_hash_rehash(VALUE hash) { VALUE tmp; diff --git a/internal.h b/internal.h index ca630ddbec..142f14dc39 100644 --- a/internal.h +++ b/internal.h @@ -838,6 +838,7 @@ st_table *rb_init_identtable_with_size(st_index_t size); #define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h) VALUE rb_hash_keys(VALUE hash); VALUE rb_hash_values(VALUE hash); +VALUE rb_hash_rehash(VALUE hash); #define HASH_DELETED FL_USER1 #define HASH_PROC_DEFAULT FL_USER2 -- cgit v1.2.3