diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | numeric.c | 24 |
2 files changed, 15 insertions, 17 deletions
@@ -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. @@ -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)) { |