mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
bignum.c: micro optimization
* bignum.c (rb_big_cmp): micro optimization of Fixnum comparison. as SIGNED_VALUE and Fixnum have same sign-bits and same order. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
be05c5798f
commit
57638377cc
1 changed files with 5 additions and 2 deletions
7
bignum.c
7
bignum.c
|
@ -5291,8 +5291,11 @@ rb_big_cmp(VALUE x, VALUE y)
|
|||
if (FIXNUM_P(y)) {
|
||||
x = bigfixize(x);
|
||||
if (FIXNUM_P(x)) {
|
||||
if (FIX2LONG(x) < FIX2LONG(y)) return INT2FIX(-1);
|
||||
return INT2FIX(FIX2LONG(x) > FIX2LONG(y));
|
||||
/* SIGNED_VALUE and Fixnum have same sign-bits, same
|
||||
* order */
|
||||
SIGNED_VALUE sx = (SIGNED_VALUE)x, sy = (SIGNED_VALUE)y;
|
||||
if (sx < sy) return INT2FIX(-1);
|
||||
return INT2FIX(sx > sy);
|
||||
}
|
||||
}
|
||||
else if (RB_BIGNUM_TYPE_P(y)) {
|
||||
|
|
Loading…
Reference in a new issue