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

ruby-changes:46321

From: ko1 <ko1@a...>
Date: Sat, 22 Apr 2017 00:00:38 +0900 (JST)
Subject: [ruby-changes:46321] ko1:r58435 (trunk): insert WB correctly.

ko1	2017-04-22 00:00:30 +0900 (Sat, 22 Apr 2017)

  New Revision: 58435

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

  Log:
    insert WB correctly.
    
    * hash.c (hash_insert_raw): should insert WB.

  Modified files:
    trunk/hash.c
Index: hash.c
===================================================================
--- hash.c	(revision 58434)
+++ hash.c	(revision 58435)
@@ -634,15 +634,19 @@ hash_alloc_from_st(VALUE klass, st_table https://github.com/ruby/ruby/blob/trunk/hash.c#L634
     return h;
 }
 
-static inline int
-hash_insert_raw(st_table *tbl, VALUE key, VALUE val)
+static inline void
+hash_insert_raw(VALUE hash, st_table *tbl, VALUE key, VALUE val)
 {
     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;
 
-    return st_insert(tbl, k, v);
+    st_insert(tbl, k, v);
+    if (hash != Qfalse) {
+	RB_OBJ_WRITTEN(hash, Qundef, key);
+	RB_OBJ_WRITTEN(hash, Qundef, val);
+    }
 }
 
 static VALUE
@@ -663,7 +667,7 @@ rb_hash_new_from_values_with_klass(long https://github.com/ruby/ruby/blob/trunk/hash.c#L667
 	VALUE key = argv[i++];
 	VALUE val = argv[i++];
 
-	hash_insert_raw(t, key, val);
+	hash_insert_raw(v, t, key, val);
     }
     return v;
 }
@@ -717,7 +721,7 @@ rb_hash_new_from_object(VALUE klass, VAL https://github.com/ruby/ruby/blob/trunk/hash.c#L721
 		val = RARRAY_AREF(v, 1);
 	    case 1:
 		key = RARRAY_AREF(v, 0);
-		hash_insert_raw(tbl, key, val);
+		hash_insert_raw(Qfalse, tbl, key, val);
 	    }
 	}
 	return hash_alloc_from_st(klass, tbl);

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

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