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:
parent
afb95d1004
commit
2293547d9b
1 changed files with 6 additions and 10 deletions
16
range.c
16
range.c
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue