diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-21 08:53:15 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-21 08:53:15 +0000 |
commit | f67795869db1cb62992d19e94bcf83abd0f0686b (patch) | |
tree | 2786b7007dc71fef2e671c4bfee06c91422e5098 /numeric.c | |
parent | e3b0b6d5fecf52402c333be90c31b32bb04c43ac (diff) | |
download | ruby-f67795869db1cb62992d19e94bcf83abd0f0686b.tar.gz |
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 24 |
1 files changed, 7 insertions, 17 deletions
@@ -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)) { |