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

Update iteration step in step_i_iter

This commit is contained in:
Nobuyoshi Nakada 2021-10-10 11:41:26 +09:00
parent afb95d1004
commit 2293547d9b
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

16
range.c
View file

@ -308,7 +308,7 @@ range_each_func(VALUE range, int (*func)(VALUE, VALUE), VALUE arg)
}
}
static VALUE*
static bool
step_i_iter(VALUE arg)
{
VALUE *iter = (VALUE *)arg;
@ -319,17 +319,16 @@ step_i_iter(VALUE arg)
else {
iter[0] = rb_funcall(iter[0], '-', 1, INT2FIX(1));
}
return iter;
if (iter[0] != INT2FIX(0)) return false;
iter[0] = iter[1];
return true;
}
static int
sym_step_i(VALUE i, VALUE arg)
{
VALUE *iter = step_i_iter(arg);
if (iter[0] == INT2FIX(0)) {
if (step_i_iter(arg)) {
rb_yield(rb_str_intern(i));
iter[0] = iter[1];
}
return 0;
}
@ -337,11 +336,8 @@ sym_step_i(VALUE i, VALUE arg)
static int
step_i(VALUE i, VALUE arg)
{
VALUE *iter = step_i_iter(arg);
if (iter[0] == INT2FIX(0)) {
if (step_i_iter(arg)) {
rb_yield(i);
iter[0] = iter[1];
}
return 0;
}