mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* numeric.c: Simplify by getting rid of macro
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
814fb8e6c7
commit
11a57c63f3
1 changed files with 5 additions and 10 deletions
15
numeric.c
15
numeric.c
|
@ -1864,14 +1864,6 @@ ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl)
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define NUM_STEP_GET_INF(to, desc, inf) do { \
|
|
||||||
if (RB_TYPE_P(to, T_FLOAT)) { \
|
|
||||||
double f = RFLOAT_VALUE(to); \
|
|
||||||
inf = isinf(f) && (signbit(f) ? desc : !desc); \
|
|
||||||
} \
|
|
||||||
else inf = 0; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
num_step_size(VALUE from, VALUE args, VALUE eobj)
|
num_step_size(VALUE from, VALUE args, VALUE eobj)
|
||||||
{
|
{
|
||||||
|
@ -1947,8 +1939,11 @@ num_step(int argc, VALUE *argv, VALUE from)
|
||||||
RETURN_SIZED_ENUMERATOR(from, argc, argv, num_step_size);
|
RETURN_SIZED_ENUMERATOR(from, argc, argv, num_step_size);
|
||||||
|
|
||||||
NUM_STEP_SCAN_ARGS(argc, argv, to, step, hash, desc);
|
NUM_STEP_SCAN_ARGS(argc, argv, to, step, hash, desc);
|
||||||
NUM_STEP_GET_INF(to, desc, inf);
|
if (RB_TYPE_P(to, T_FLOAT)) {
|
||||||
|
double f = RFLOAT_VALUE(to);
|
||||||
|
inf = isinf(f) && (signbit(f) ? desc : !desc);
|
||||||
|
}
|
||||||
|
else inf = 0;
|
||||||
|
|
||||||
if (FIXNUM_P(from) && (inf || FIXNUM_P(to)) && FIXNUM_P(step)) {
|
if (FIXNUM_P(from) && (inf || FIXNUM_P(to)) && FIXNUM_P(step)) {
|
||||||
long i = FIX2LONG(from);
|
long i = FIX2LONG(from);
|
||||||
|
|
Loading…
Add table
Reference in a new issue