diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-21 15:00:30 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-21 15:00:30 +0000 |
commit | 5f5bc068ed7358be7975d0887d48d2c26e7f9847 (patch) | |
tree | b6a2967bf933f7c408b6116afe594bc00c01c614 | |
parent | a7db63208833d69ba02ef5ad21d32017f148bc46 (diff) | |
download | ruby-5f5bc068ed7358be7975d0887d48d2c26e7f9847.tar.gz |
insert WB correctly.
* hash.c (hash_insert_raw): should insert WB.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | hash.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -634,15 +634,19 @@ hash_alloc_from_st(VALUE klass, st_table *ntbl) 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 argc, const VALUE *argv, VALUE klass) 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, VALUE obj) 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); |