[前][次][番号順一覧][スレッド一覧]

ruby-changes:40952

From: nobu <ko1@a...>
Date: Fri, 11 Dec 2015 11:38:46 +0900 (JST)
Subject: [ruby-changes:40952] nobu:r53031 (trunk): compile.c: rehash cdhash

nobu	2015-12-11 11:38:20 +0900 (Fri, 11 Dec 2015)

  New Revision: 53031

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53031

  Log:
    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

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
    trunk/hash.c
    trunk/internal.h
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53030)
+++ ChangeLog	(revision 53031)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Dec 11 11:38:14 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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  <naruse@r...>
 
 	* object.c (rb_inspect): dump inspected result with rb_str_escape()
Index: compile.c
===================================================================
--- compile.c	(revision 53030)
+++ compile.c	(revision 53031)
@@ -1640,6 +1640,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L1640
                             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_lo https://github.com/ruby/ruby/blob/trunk/compile.c#L7737
 	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);
Index: hash.c
===================================================================
--- hash.c	(revision 53030)
+++ hash.c	(revision 53031)
@@ -734,7 +734,7 @@ rb_hash_rehash_i(VALUE key, VALUE value, https://github.com/ruby/ruby/blob/trunk/hash.c#L734
  *     h[a]       #=> 100
  */
 
-static VALUE
+VALUE
 rb_hash_rehash(VALUE hash)
 {
     VALUE tmp;
Index: internal.h
===================================================================
--- internal.h	(revision 53030)
+++ internal.h	(revision 53031)
@@ -838,6 +838,7 @@ st_table *rb_init_identtable_with_size(s https://github.com/ruby/ruby/blob/trunk/internal.h#L838
 #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
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]