зеркало из https://github.com/github/ruby.git
Refactor sym_step_i function
This commit is contained in:
Родитель
f6048e592c
Коммит
afb95d1004
20
range.c
20
range.c
|
@ -308,8 +308,8 @@ range_each_func(VALUE range, int (*func)(VALUE, VALUE), VALUE arg)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
sym_step_i(VALUE i, VALUE arg)
|
||||
static VALUE*
|
||||
step_i_iter(VALUE arg)
|
||||
{
|
||||
VALUE *iter = (VALUE *)arg;
|
||||
|
||||
|
@ -319,6 +319,14 @@ sym_step_i(VALUE i, VALUE arg)
|
|||
else {
|
||||
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)) {
|
||||
rb_yield(rb_str_intern(i));
|
||||
iter[0] = iter[1];
|
||||
|
@ -329,14 +337,8 @@ sym_step_i(VALUE i, VALUE arg)
|
|||
static int
|
||||
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)) {
|
||||
rb_yield(i);
|
||||
iter[0] = iter[1];
|
||||
|
|
Загрузка…
Ссылка в новой задаче