summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-24 15:28:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-24 15:28:30 +0000
commitd617a02b14b170219eb0f4b0cff23360e6fb4fc4 (patch)
treeafb398432e261f5d773036a2b5d0b9c39254f421 /vm.c
parentf9382d033c03bc2d2d032db87c6bf65e0ab3f4fa (diff)
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.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/vm.c b/vm.c
index 2e26e8c..b0597af 100644
--- a/vm.c
+++ b/vm.c
@@ -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