Refactor sym_step_i function
This commit is contained in:
parent
f6048e592c
commit
afb95d1004
Notes:
git
2021-10-10 11:40:24 +09:00
Merged: https://github.com/ruby/ruby/pull/4923 Merged-By: nobu <nobu@ruby-lang.org>
20
range.c
20
range.c
@ -308,8 +308,8 @@ range_each_func(VALUE range, int (*func)(VALUE, VALUE), VALUE arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static VALUE*
|
||||||
sym_step_i(VALUE i, VALUE arg)
|
step_i_iter(VALUE arg)
|
||||||
{
|
{
|
||||||
VALUE *iter = (VALUE *)arg;
|
VALUE *iter = (VALUE *)arg;
|
||||||
|
|
||||||
@ -319,6 +319,14 @@ sym_step_i(VALUE i, VALUE arg)
|
|||||||
else {
|
else {
|
||||||
iter[0] = rb_funcall(iter[0], '-', 1, INT2FIX(1));
|
iter[0] = rb_funcall(iter[0], '-', 1, INT2FIX(1));
|
||||||
}
|
}
|
||||||
|
return iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
sym_step_i(VALUE i, VALUE arg)
|
||||||
|
{
|
||||||
|
VALUE *iter = step_i_iter(arg);
|
||||||
|
|
||||||
if (iter[0] == INT2FIX(0)) {
|
if (iter[0] == INT2FIX(0)) {
|
||||||
rb_yield(rb_str_intern(i));
|
rb_yield(rb_str_intern(i));
|
||||||
iter[0] = iter[1];
|
iter[0] = iter[1];
|
||||||
@ -329,14 +337,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 = (VALUE *)arg;
|
VALUE *iter = step_i_iter(arg);
|
||||||
|
|
||||||
if (FIXNUM_P(iter[0])) {
|
|
||||||
iter[0] -= INT2FIX(1) & ~FIXNUM_FLAG;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
iter[0] = rb_funcall(iter[0], '-', 1, INT2FIX(1));
|
|
||||||
}
|
|
||||||
if (iter[0] == INT2FIX(0)) {
|
if (iter[0] == INT2FIX(0)) {
|
||||||
rb_yield(i);
|
rb_yield(i);
|
||||||
iter[0] = iter[1];
|
iter[0] = iter[1];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user