[前][次][番号順一覧][スレッド一覧]

ruby-changes:33320

From: nobu <ko1@a...>
Date: Tue, 25 Mar 2014 00:28:33 +0900 (JST)
Subject: [ruby-changes:33320] nobu:r45399 (trunk): vm.c: merge code

nobu	2014-03-25 00:28:30 +0900 (Tue, 25 Mar 2014)

  New Revision: 45399

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45399

  Log:
    vm.c: merge code
    
    * vm.c (m_core_hash_from_ary, m_core_hash_merge_ary): merge
      duplicated code.

  Modified files:
    trunk/vm.c
Index: vm.c
===================================================================
--- vm.c	(revision 45398)
+++ vm.c	(revision 45399)
@@ -2250,22 +2250,18 @@ m_core_set_postexe(VALUE self) https://github.com/ruby/ruby/blob/trunk/vm.c#L2250
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]