diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-23 04:04:14 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-23 04:04:14 +0000 |
commit | 38c8efbe2d24fdf5762beeda1075331dc5a5253e (patch) | |
tree | b57724201e45810e9303abe4e5fdd60ed550c217 /numeric.c | |
parent | 6a9c00dd65779b4ec75a27d8f56fd2a78855573d (diff) |
* numeric.c (fix_cmp, fix_equal): Remove FIX2LONG() to optimize.
suggested in
http://t-a-w.blogspot.com/2007/02/making-ruby-faster.html.
[ruby-talk:240223]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -2226,12 +2226,9 @@ static VALUE fix_equal(x, y) VALUE x, y; { - if (FIXNUM_P(y)) { - return (FIX2LONG(x) == FIX2LONG(y))?Qtrue:Qfalse; - } - else { - return num_equal(x, y); - } + if (x == y) return Qtrue; + if (FIXNUM_P(y)) return Qfalse; + return num_equal(x, y); } /* @@ -2247,10 +2244,10 @@ static VALUE fix_cmp(x, y) VALUE x, 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); return INT2FIX(-1); } |