aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--numeric.c24
2 files changed, 15 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 09ca332cc8..e6b7903dd3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Wed Feb 21 17:40:37 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (fix_equal): remove FIX2LONG() to optimize. suggested
+ in http://t-a-w.blogspot.com/2007/02/making-ruby-faster.html.
+ [ruby-talk:240223]
+
+ * numeric.c (fix_cmp): ditto.
+
Wed Feb 21 09:14:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval_load.c (rb_require_safe): should restore safe level.
diff --git a/numeric.c b/numeric.c
index f07bed4799..c94eb63b94 100644
--- a/numeric.c
+++ b/numeric.c
@@ -2312,7 +2312,7 @@ static VALUE
fix_equal(VALUE x, VALUE y)
{
if (FIXNUM_P(y)) {
- return (FIX2LONG(x) == FIX2LONG(y))?Qtrue:Qfalse;
+ return (x == y)?Qtrue:Qfalse;
}
switch (TYPE(y)) {
case T_BIGNUM:
@@ -2336,11 +2336,9 @@ fix_equal(VALUE x, VALUE y)
static VALUE
fix_cmp(VALUE x, VALUE y)
{
+ if (x == y) return INT2FIX(0);
if (FIXNUM_P(y)) {
- long a = FIX2LONG(x), b = FIX2LONG(y);
-
- if (a == b) return INT2FIX(0);
- if (a > b) return INT2FIX(1);
+ if (FIX2LONG(x) > FIX2LONG(y)) return INT2FIX(1);
return INT2FIX(-1);
}
switch (TYPE(y)) {
@@ -2365,9 +2363,7 @@ static VALUE
fix_gt(VALUE x, VALUE y)
{
if (FIXNUM_P(y)) {
- long a = FIX2LONG(x), b = FIX2LONG(y);
-
- if (a > b) return Qtrue;
+ if (FIX2LONG(x) > FIX2LONG(y)) return Qtrue;
return Qfalse;
}
switch (TYPE(y)) {
@@ -2392,9 +2388,7 @@ static VALUE
fix_ge(VALUE x, VALUE y)
{
if (FIXNUM_P(y)) {
- long a = FIX2LONG(x), b = FIX2LONG(y);
-
- if (a >= b) return Qtrue;
+ if (FIX2LONG(x) >= FIX2LONG(y)) return Qtrue;
return Qfalse;
}
switch (TYPE(y)) {
@@ -2419,9 +2413,7 @@ static VALUE
fix_lt(VALUE x, VALUE y)
{
if (FIXNUM_P(y)) {
- long a = FIX2LONG(x), b = FIX2LONG(y);
-
- if (a < b) return Qtrue;
+ if (FIX2LONG(x) < FIX2LONG(y)) return Qtrue;
return Qfalse;
}
switch (TYPE(y)) {
@@ -2446,9 +2438,7 @@ static VALUE
fix_le(VALUE x, VALUE y)
{
if (FIXNUM_P(y)) {
- long a = FIX2LONG(x), b = FIX2LONG(y);
-
- if (a <= b) return Qtrue;
+ if (FIX2LONG(x) <= FIX2LONG(y)) return Qtrue;
return Qfalse;
}
switch (TYPE(y)) {