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

ruby-changes:37308

From: nobu <ko1@a...>
Date: Fri, 23 Jan 2015 20:01:18 +0900 (JST)
Subject: [ruby-changes:37308] nobu:r49389 (trunk): marshal.c: indetity tables

nobu	2015-01-23 20:01:02 +0900 (Fri, 23 Jan 2015)

  New Revision: 49389

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

  Log:
    marshal.c: indetity tables
    
    * marshal.c (w_object, marshal_dump): use indetity tables for
      arbitrary VALUE keys, because of performance of FLONUM.
      [Bug #10761]
    * marshal.c (obj_alloc_by_klass, marshal_load): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/hash.c
    trunk/internal.h
    trunk/marshal.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49388)
+++ ChangeLog	(revision 49389)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jan 23 20:00:59 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* marshal.c (w_object, marshal_dump): use indetity tables for
+	  arbitrary VALUE keys, because of performance of FLONUM.
+	  [Bug #10761]
+
+	* marshal.c (obj_alloc_by_klass, marshal_load): ditto.
+
 Fri Jan 23 17:12:33 2015  Eric Wong  <e@8...>
 
 	* benchmark/bm_marshal_dump_flo.rb: new benchmark for [Bug #10761]
Index: hash.c
===================================================================
--- hash.c	(revision 49388)
+++ hash.c	(revision 49389)
@@ -2549,6 +2549,18 @@ rb_ident_hash_new(void) https://github.com/ruby/ruby/blob/trunk/hash.c#L2549
     return hash;
 }
 
+st_table *
+rb_init_identtable(void)
+{
+    return st_init_table(&identhash);
+}
+
+st_table *
+rb_init_identtable_with_size(st_index_t size)
+{
+    return st_init_table_with_size(&identhash, size);
+}
+
 static int
 any_p_i(VALUE key, VALUE value, VALUE arg)
 {
Index: internal.h
===================================================================
--- internal.h	(revision 49388)
+++ internal.h	(revision 49389)
@@ -702,6 +702,8 @@ VALUE rb_hash_has_key(VALUE hash, VALUE https://github.com/ruby/ruby/blob/trunk/internal.h#L702
 VALUE rb_hash_set_default_proc(VALUE hash, VALUE proc);
 long rb_objid_hash(st_index_t index);
 VALUE rb_ident_hash_new(void);
+st_table *rb_init_identtable(void);
+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);
Index: marshal.c
===================================================================
--- marshal.c	(revision 49388)
+++ marshal.c	(revision 49389)
@@ -748,7 +748,7 @@ w_object(VALUE obj, struct dump_arg *arg https://github.com/ruby/ruby/blob/trunk/marshal.c#L748
                 VALUE real_obj = obj;
                 obj = compat->dumper(real_obj);
                 if (!arg->compat_tbl) {
-                    arg->compat_tbl = st_init_numtable();
+                    arg->compat_tbl = rb_init_identtable();
                 }
                 st_insert(arg->compat_tbl, (st_data_t)obj, (st_data_t)real_obj);
 		if (obj != real_obj && !ivtbl) hasiv = 0;
@@ -997,7 +997,7 @@ marshal_dump(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/marshal.c#L997
     wrapper = TypedData_Make_Struct(rb_cData, struct dump_arg, &dump_arg_data, arg);
     arg->dest = 0;
     arg->symbols = st_init_numtable();
-    arg->data    = st_init_numtable();
+    arg->data    = rb_init_identtable();
     arg->infection = 0;
     arg->compat_tbl = 0;
     arg->encodings = 0;
@@ -1507,7 +1507,7 @@ obj_alloc_by_klass(VALUE klass, struct l https://github.com/ruby/ruby/blob/trunk/marshal.c#L1507
 	if (oldclass) *oldclass = compat->oldclass;
 
         if (!arg->compat_tbl) {
-            arg->compat_tbl = st_init_numtable();
+            arg->compat_tbl = rb_init_identtable();
         }
         st_insert(arg->compat_tbl, (st_data_t)obj, (st_data_t)real_obj);
         return obj;
@@ -2016,7 +2016,7 @@ marshal_load(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/marshal.c#L2016
     arg->src = port;
     arg->offset = 0;
     arg->symbols = st_init_numtable();
-    arg->data    = st_init_numtable();
+    arg->data    = rb_init_identtable();
     arg->compat_tbl = 0;
     arg->proc = 0;
     arg->readable = 0;

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

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