зеркало из https://github.com/github/ruby.git
* 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:
Родитель
f9810d26b1
Коммит
dfd26e3a47
|
@ -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.
|
||||
|
|
18
bignum.c
18
bignum.c
|
@ -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)) {
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче