diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-26 01:52:00 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-26 01:52:00 +0000 |
commit | f7cdac1f30117b2e3923c7f654c50677d21e4ed0 (patch) | |
tree | cca206ca0d66fa76ad4845dff694569c96cb3377 /numeric.c | |
parent | 68cabe824caeaab8d837b259630fdd66a566f6a3 (diff) | |
download | ruby-f7cdac1f30117b2e3923c7f654c50677d21e4ed0.tar.gz |
numeric.c: Fixnum predicts
* numeric.c (FIXNUM_{POSITIVE,NEGATIVE,ZERO}_P): predict macros
only for Fixnum.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -173,6 +173,10 @@ compare_with_zero(VALUE num, ID mid) return r; } +#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 positive_int_p(VALUE num) { @@ -180,7 +184,7 @@ positive_int_p(VALUE num) if (FIXNUM_P(num)) { if (method_basic_p(rb_cFixnum)) - return (SIGNED_VALUE)num > 0; + return FIXNUM_POSITIVE_P(num); } else if (RB_TYPE_P(num, T_BIGNUM)) { if (method_basic_p(rb_cBignum)) @@ -196,7 +200,7 @@ negative_int_p(VALUE num) if (FIXNUM_P(num)) { if (method_basic_p(rb_cFixnum)) - return (SIGNED_VALUE)num < 0; + return FIXNUM_NEGATIVE_P(num); } else if (RB_TYPE_P(num, T_BIGNUM)) { if (method_basic_p(rb_cBignum)) |