summaryrefslogtreecommitdiff
path: root/enum.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-15 05:25:36 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-15 05:25:36 (GMT)
commitefaed8c80d12e5f2be76f0c6b25bd3aba180c97c (patch)
treefcae159f8f727039d4911bffa3b65bb05abac0fb /enum.c
parent2386407223a5074a25e1a3827ed2e1be81ec3a40 (diff)
enum.c: use Qundef
* enum.c (enum_inject): use Qundef for no initial values. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enum.c')
-rw-r--r--enum.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/enum.c b/enum.c
index 205664f..b139b69 100644
--- a/enum.c
+++ b/enum.c
@@ -555,8 +555,7 @@ inject_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, p))
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, p))
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 obj)
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 obj)
}
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 obj)
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;
}