1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2014-03-24 15:28:30 +00:00
parent f9382d033c
commit d617a02b14

10
vm.c
View file

@ -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