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

ruby-changes:35844

From: nobu <ko1@a...>
Date: Wed, 15 Oct 2014 14:25:50 +0900 (JST)
Subject: [ruby-changes:35844] nobu:r47926 (trunk): enum.c: use Qundef

nobu	2014-10-15 14:25:36 +0900 (Wed, 15 Oct 2014)

  New Revision: 47926

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

  Log:
    enum.c: use Qundef
    
    * enum.c (enum_inject): use Qundef for no initial values.

  Modified files:
    trunk/enum.c
Index: enum.c
===================================================================
--- enum.c	(revision 47925)
+++ enum.c	(revision 47926)
@@ -555,8 +555,7 @@ inject_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, p https://github.com/ruby/ruby/blob/trunk/enum.c#L555
 
     ENUM_WANT_SVALUE();
 
-    if (memo->u2.argc == 0) {
-	memo->u2.argc = 1;
+    if (memo->u1.value == Qundef) {
 	memo->u1.value = i;
     }
     else {
@@ -573,12 +572,12 @@ inject_op_i(RB_BLOCK_CALL_FUNC_ARGLIST(i https://github.com/ruby/ruby/blob/trunk/enum.c#L572
 
     ENUM_WANT_SVALUE();
 
-    if (memo->u2.argc == 0) {
-	memo->u2.argc = 1;
+    if (memo->u1.value == Qundef) {
 	memo->u1.value = i;
     }
     else if (SYMBOL_P(name = memo->u3.value)) {
-	memo->u1.value = rb_funcall(memo->u1.value, SYM2ID(name), 1, i);
+	const ID mid = SYM2ID(name);
+	memo->u1.value = rb_funcall(memo->u1.value, mid, 1, i);
     }
     else {
 	VALUE args[2];
@@ -642,6 +641,7 @@ enum_inject(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/enum.c#L641
 
     switch (rb_scan_args(argc, argv, "02", &init, &op)) {
       case 0:
+	init = Qundef;
 	break;
       case 1:
 	if (rb_block_given_p()) {
@@ -649,8 +649,7 @@ enum_inject(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/enum.c#L649
 	}
 	id = rb_check_id(&init);
 	op = id ? ID2SYM(id) : init;
-	argc = 0;
-	init = Qnil;
+	init = Qundef;
 	iter = inject_op_i;
 	break;
       case 2:
@@ -662,7 +661,7 @@ enum_inject(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/enum.c#L661
 	iter = inject_op_i;
 	break;
     }
-    memo = NEW_MEMO(init, argc, op);
+    memo = NEW_MEMO(init, Qnil, op);
     rb_block_call(obj, id_each, 0, 0, iter, (VALUE)memo);
     return memo->u1.value;
 }

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

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