diff options
author | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-11 14:39:25 +0000 |
---|---|---|
committer | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-11 14:39:25 +0000 |
commit | f64a53462eb5ae940ba42b5e960351bfacc7c1bb (patch) | |
tree | 6920bdab879a8601406157299afeeac4ec82289f /numeric.c | |
parent | 8ee8c5eeb6fb3c0038f4f5e9a41e6cd4627364f7 (diff) | |
download | ruby-f64a53462eb5ae940ba42b5e960351bfacc7c1bb.tar.gz |
numeric.c, rational.c: refactor by using FIXNUM_NEGATIVE_P and FIXNUM_ZERO_P
* numeric.c (num_zero_p, fix_divide, fix_mod, fix_divmod): refactor by using
FIXNUM_NEGATIVE_P and FIXNUM_ZERO_P.
* rational.c (INT_NEGATIVE_P, INT_ZERO_P): ditto.
* internal.h: move FIXNUM_NEGATIVE_P and FIXNUM_ZERO_P from numeric.c
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -262,8 +262,6 @@ compare_with_zero(VALUE num, ID mid) } #define FIXNUM_POSITIVE_P(num) ((SIGNED_VALUE)(num) > (SIGNED_VALUE)INT2FIX(0)) -#define FIXNUM_NEGATIVE_P(num) ((SIGNED_VALUE)(num) < 0) -#define FIXNUM_ZERO_P(num) ((num) == INT2FIX(0)) static inline int int_pos_p(VALUE num) @@ -784,7 +782,7 @@ static VALUE num_zero_p(VALUE num) { if (FIXNUM_P(num)) { - if (FIX2LONG(num) == 0) { + if (FIXNUM_ZERO_P(num)) { return Qtrue; } } @@ -3608,7 +3606,7 @@ static VALUE fix_divide(VALUE x, VALUE y, ID op) { if (FIXNUM_P(y)) { - if (FIX2LONG(y) == 0) rb_num_zerodiv(); + if (FIXNUM_ZERO_P(y)) rb_num_zerodiv(); return rb_fix_div_fix(x, y); } else if (RB_TYPE_P(y, T_BIGNUM)) { @@ -3699,7 +3697,7 @@ static VALUE fix_mod(VALUE x, VALUE y) { if (FIXNUM_P(y)) { - if (FIX2LONG(y) == 0) rb_num_zerodiv(); + if (FIXNUM_ZERO_P(y)) rb_num_zerodiv(); return rb_fix_mod_fix(x, y); } else if (RB_TYPE_P(y, T_BIGNUM)) { @@ -3772,7 +3770,7 @@ fix_divmod(VALUE x, VALUE y) { if (FIXNUM_P(y)) { VALUE div, mod; - if (FIX2LONG(y) == 0) rb_num_zerodiv(); + if (FIXNUM_ZERO_P(y)) rb_num_zerodiv(); rb_fix_divmod_fix(x, y, &div, &mod); return rb_assoc_new(div, mod); } |