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

ruby-changes:46320

From: ko1 <ko1@a...>
Date: Fri, 21 Apr 2017 20:02:15 +0900 (JST)
Subject: [ruby-changes:46320] ko1:r58434 (trunk): mark created frozen strings.

ko1	2017-04-21 20:02:10 +0900 (Fri, 21 Apr 2017)

  New Revision: 58434

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

  Log:
    mark created frozen strings.
    
    * hash.c (rb_hash_new_from_values_with_klass): before this fix,
      only a st table are filled with passed values. However, newly
      created frozen strings are not marked correctly only reference
      from st table. This patch marks such created frozen strings
      by Hash object which refers to the st table.

  Modified files:
    trunk/hash.c
Index: hash.c
===================================================================
--- hash.c	(revision 58433)
+++ hash.c	(revision 58434)
@@ -639,8 +639,8 @@ hash_insert_raw(st_table *tbl, VALUE key https://github.com/ruby/ruby/blob/trunk/hash.c#L639
 {
     st_data_t v = (st_data_t)val;
     st_data_t k = (rb_obj_class(key) == rb_cString) ?
-	(st_data_t)rb_str_new_frozen(key) :
-	(st_data_t)key;
+        (st_data_t)rb_str_new_frozen(key) :
+        (st_data_t)key;
 
     return st_insert(tbl, k, v);
 }
@@ -650,19 +650,22 @@ rb_hash_new_from_values_with_klass(long https://github.com/ruby/ruby/blob/trunk/hash.c#L650
 {
     long i;
     st_table *t;
+    VALUE v;
 
     if (argc % 2) {
 	rb_raise(rb_eArgError, "odd number of arguments for Hash");
     }
 
     t = st_init_table_with_size(&objhash, argc / 2);
+    v = hash_alloc_from_st(klass, t);
+
     for (i = 0; i < argc; /* */) {
 	VALUE key = argv[i++];
 	VALUE val = argv[i++];
 
 	hash_insert_raw(t, key, val);
     }
-    return hash_alloc_from_st(klass, t);
+    return v;
 }
 
 VALUE

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

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