summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-11 14:43:23 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-11 14:43:23 +0000
commitc1de2f4e3aa23cac7973ceb3f6c5477924c0d0ee (patch)
tree809501c78c6314b9024a3cbcc3fb9428298af766
parentab67419b755af54aeee3319a1cddb62408f1dcc9 (diff)
* bignum.c (rb_big_cmp): Specialize a comparison to zero.
* ext/bigdecimal/bigdecimal.c (is_negative): Use rb_big_cmp instead of RBIGNUM_NEGATIVE_P. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--bignum.c7
-rw-r--r--ext/bigdecimal/bigdecimal.c2
3 files changed, 14 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index c70f8cb..025a181 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Tue Feb 11 23:42:27 2014 Tanaka Akira <akr@fsij.org>
+
+ * bignum.c (rb_big_cmp): Specialize a comparison to zero.
+
+ * ext/bigdecimal/bigdecimal.c (is_negative): Use rb_big_cmp instead of
+ RBIGNUM_NEGATIVE_P.
+
Tue Feb 11 22:59:10 2014 Tanaka Akira <akr@fsij.org>
* ext/openssl/ossl_bn.c (ossl_bn_initialize): Use rb_integer_pack.
diff --git a/bignum.c b/bignum.c
index 6c2cda3..daaff25 100644
--- a/bignum.c
+++ b/bignum.c
@@ -5395,7 +5395,12 @@ rb_big_cmp(VALUE x, VALUE y)
{
int cmp;
- if (FIXNUM_P(y)) {
+ 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));
}
else if (RB_BIGNUM_TYPE_P(y)) {
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 206e5d3..f426a45 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -2095,7 +2095,7 @@ is_negative(VALUE x)
return FIX2LONG(x) < 0;
}
else if (RB_TYPE_P(x, T_BIGNUM)) {
- return RBIGNUM_NEGATIVE_P(x);
+ return FIX2INT(rb_big_cmp(x, INT2FIX(0))) < 0;
}
else if (RB_TYPE_P(x, T_FLOAT)) {
return RFLOAT_VALUE(x) < 0.0;