1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* bignum.c (rb_big_cmp): Avoid bignum allocation for comparison

between bignum and fixnum.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2014-02-15 02:48:44 +00:00
parent f9810d26b1
commit dfd26e3a47
2 changed files with 16 additions and 7 deletions

View file

@ -1,3 +1,8 @@
Sat Feb 15 11:47:47 2014 Tanaka Akira <akr@fsij.org>
* bignum.c (rb_big_cmp): Avoid bignum allocation for comparison
between bignum and fixnum.
Sat Feb 15 10:55:12 2014 Hiroshi Shirosaki <h.shirosaki@gmail.com>
* ext/-test-/win32/fd_setsize/depend: fix wrong dependencies.

View file

@ -5277,13 +5277,17 @@ rb_big_cmp(VALUE x, VALUE y)
{
int cmp;
if (y == INT2FIX(0)) {
if (BIGZEROP(x)) return INT2FIX(0);
if (RBIGNUM_NEGATIVE_P(x)) return INT2FIX(-1);
return INT2FIX(1);
}
else if (FIXNUM_P(y)) {
y = rb_int2big(FIX2LONG(y));
if (FIXNUM_P(y)) {
x = bignorm(x);
if (FIXNUM_P(x)) {
if (FIX2LONG(x) > FIX2LONG(y)) return INT2FIX(1);
if (FIX2LONG(x) < FIX2LONG(y)) return INT2FIX(-1);
return INT2FIX(0);
}
else {
if (RBIGNUM_NEGATIVE_P(x)) return INT2FIX(-1);
return INT2FIX(1);
}
}
else if (RB_BIGNUM_TYPE_P(y)) {
}