mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
3f519a7bfa
commit
ed47a0ec80
2 changed files with 11 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Mar 26 10:51:58 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* numeric.c (FIXNUM_{POSITIVE,NEGATIVE,ZERO}_P): predict macros
|
||||||
|
only for Fixnum.
|
||||||
|
|
||||||
Sat Mar 26 06:34:24 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
Sat Mar 26 06:34:24 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* localeinit.c (rb_locale_charmap_index): fix prototype.
|
* localeinit.c (rb_locale_charmap_index): fix prototype.
|
||||||
|
|
|
@ -173,6 +173,10 @@ compare_with_zero(VALUE num, ID mid)
|
||||||
return r;
|
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
|
static inline int
|
||||||
positive_int_p(VALUE num)
|
positive_int_p(VALUE num)
|
||||||
{
|
{
|
||||||
|
@ -180,7 +184,7 @@ positive_int_p(VALUE num)
|
||||||
|
|
||||||
if (FIXNUM_P(num)) {
|
if (FIXNUM_P(num)) {
|
||||||
if (method_basic_p(rb_cFixnum))
|
if (method_basic_p(rb_cFixnum))
|
||||||
return (SIGNED_VALUE)num > 0;
|
return FIXNUM_POSITIVE_P(num);
|
||||||
}
|
}
|
||||||
else if (RB_TYPE_P(num, T_BIGNUM)) {
|
else if (RB_TYPE_P(num, T_BIGNUM)) {
|
||||||
if (method_basic_p(rb_cBignum))
|
if (method_basic_p(rb_cBignum))
|
||||||
|
@ -196,7 +200,7 @@ negative_int_p(VALUE num)
|
||||||
|
|
||||||
if (FIXNUM_P(num)) {
|
if (FIXNUM_P(num)) {
|
||||||
if (method_basic_p(rb_cFixnum))
|
if (method_basic_p(rb_cFixnum))
|
||||||
return (SIGNED_VALUE)num < 0;
|
return FIXNUM_NEGATIVE_P(num);
|
||||||
}
|
}
|
||||||
else if (RB_TYPE_P(num, T_BIGNUM)) {
|
else if (RB_TYPE_P(num, T_BIGNUM)) {
|
||||||
if (method_basic_p(rb_cBignum))
|
if (method_basic_p(rb_cBignum))
|
||||||
|
|
Loading…
Reference in a new issue