diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-24 01:40:51 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-24 01:40:51 +0000 |
commit | e8c55ea540f85fffdba99d003e9cc363c5888515 (patch) | |
tree | 2b635425fb05d3325a5c58ed0c0de6801f950ce3 /vm.c | |
parent | cf5979fa7ceb4dce319a42541fc6cc322fd9a821 (diff) | |
download | ruby-e8c55ea540f85fffdba99d003e9cc363c5888515.tar.gz |
revert newhash refactoring
We need to fix GC bug before merging this. Revert revisions
58452, 58435, 58434, 58428, 58427 in this order.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 31 |
1 files changed, 21 insertions, 10 deletions
@@ -2646,6 +2646,7 @@ m_core_set_postexe(VALUE self) return Qnil; } +static VALUE core_hash_merge_ary(VALUE hash, VALUE ary); static VALUE core_hash_from_ary(VALUE ary); static VALUE core_hash_merge_kwd(int argc, VALUE *argv); @@ -2655,6 +2656,7 @@ core_hash_merge(VALUE hash, long argc, const VALUE *argv) long i; Check_Type(hash, T_HASH); + VM_ASSERT(argc % 2 == 0); for (i=0; i<argc; i+=2) { rb_hash_aset(hash, argv[i], argv[i+1]); } @@ -2672,18 +2674,27 @@ m_core_hash_from_ary(VALUE self, VALUE ary) static VALUE core_hash_from_ary(VALUE ary) { - long n; + VALUE hash = rb_hash_new(); + RUBY_DTRACE_CREATE_HOOK(HASH, (Check_Type(ary, T_ARRAY), RARRAY_LEN(ary))); + return core_hash_merge_ary(hash, ary); +} + +#if 0 +static VALUE +m_core_hash_merge_ary(VALUE self, VALUE hash, VALUE ary) +{ + REWIND_CFP(core_hash_merge_ary(hash, ary)); + return hash; +} +#endif + +static VALUE +core_hash_merge_ary(VALUE hash, VALUE ary) +{ Check_Type(ary, T_ARRAY); - n = RARRAY_LEN(ary); - RUBY_DTRACE_CREATE_HOOK(HASH, n); - if (n) { - VM_ASSERT(n % 2 == 0); - return rb_hash_new_from_values(n, RARRAY_PTR(ary)); - } - else { - return rb_hash_new(); - } + core_hash_merge(hash, RARRAY_LEN(ary), RARRAY_CONST_PTR(ary)); + return hash; } static VALUE |