Update iteration step in step_i_iter
This commit is contained in:
parent
afb95d1004
commit
2293547d9b
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)
|
step_i_iter(VALUE arg)
|
||||||
{
|
{
|
||||||
VALUE *iter = (VALUE *)arg;
|
VALUE *iter = (VALUE *)arg;
|
||||||
@ -319,17 +319,16 @@ step_i_iter(VALUE arg)
|
|||||||
else {
|
else {
|
||||||
iter[0] = rb_funcall(iter[0], '-', 1, INT2FIX(1));
|
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
|
static int
|
||||||
sym_step_i(VALUE i, VALUE arg)
|
sym_step_i(VALUE i, VALUE arg)
|
||||||
{
|
{
|
||||||
VALUE *iter = step_i_iter(arg);
|
if (step_i_iter(arg)) {
|
||||||
|
|
||||||
if (iter[0] == INT2FIX(0)) {
|
|
||||||
rb_yield(rb_str_intern(i));
|
rb_yield(rb_str_intern(i));
|
||||||
iter[0] = iter[1];
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -337,11 +336,8 @@ sym_step_i(VALUE i, VALUE arg)
|
|||||||
static int
|
static int
|
||||||
step_i(VALUE i, VALUE arg)
|
step_i(VALUE i, VALUE arg)
|
||||||
{
|
{
|
||||||
VALUE *iter = step_i_iter(arg);
|
if (step_i_iter(arg)) {
|
||||||
|
|
||||||
if (iter[0] == INT2FIX(0)) {
|
|
||||||
rb_yield(i);
|
rb_yield(i);
|
||||||
iter[0] = iter[1];
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user