diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-03-24 15:28:30 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-03-24 15:28:30 +0000 |
commit | d617a02b14b170219eb0f4b0cff23360e6fb4fc4 (patch) | |
tree | afb398432e261f5d773036a2b5d0b9c39254f421 /vm.c | |
parent | f9382d033c03bc2d2d032db87c6bf65e0ab3f4fa (diff) | |
download | ruby-d617a02b14b170219eb0f4b0cff23360e6fb4fc4.tar.gz |
vm.c: merge code
* vm.c (m_core_hash_from_ary, m_core_hash_merge_ary): merge
duplicated code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 10 |
1 files changed, 3 insertions, 7 deletions
@@ -2250,22 +2250,18 @@ m_core_set_postexe(VALUE self) return Qnil; } +static VALUE m_core_hash_merge_ary(VALUE self, VALUE hash, VALUE ary); + static VALUE m_core_hash_from_ary(VALUE self, VALUE ary) { VALUE hash = rb_hash_new(); - int i; if (RUBY_DTRACE_HASH_CREATE_ENABLED()) { RUBY_DTRACE_HASH_CREATE(RARRAY_LEN(ary), rb_sourcefile(), rb_sourceline()); } - assert(RARRAY_LEN(ary) % 2 == 0); - for (i=0; i<RARRAY_LEN(ary); i+=2) { - rb_hash_aset(hash, RARRAY_AREF(ary, i), RARRAY_AREF(ary, i+1)); - } - - return hash; + return m_core_hash_merge_ary(self, hash, ary); } static VALUE |