diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-04 00:45:02 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-04 00:45:02 +0000 |
commit | 9c50406bd5892c95d76e966c1db8b85c4b5fbe32 (patch) | |
tree | 986bf6d2b081bd36ad3843c0cefd928fc38c66da /time.c | |
parent | eb71e5cd67f4ce4da5ba331f93a8e36c65457b94 (diff) | |
download | ruby-9c50406bd5892c95d76e966c1db8b85c4b5fbe32.tar.gz |
* time.c (lt): call <=> instead of <.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r-- | time.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -31,6 +31,8 @@ static ID id_eq, id_ne, id_quo, id_div, id_cmp, id_lshift; #define NMOD(x,y) ((y)-(-((x)+1)%(y))-1) #define DIV(n,d) ((n)<0 ? NDIV((n),(d)) : (n)/(d)) +#define cmp(x,y) (rb_cmpint(rb_funcall((x), id_cmp, 1, (y)), (x), (y))) + static int eq(VALUE x, VALUE y) { @@ -46,7 +48,7 @@ lt(VALUE x, VALUE y) if (FIXNUM_P(x) && FIXNUM_P(y)) { return (long)x < (long)y; } - return RTEST(rb_funcall(x, '<', 1, y)); + return cmp(x,y) < 0; } #define ne(x,y) (!eq(x,y)) @@ -154,7 +156,6 @@ mod(VALUE x, VALUE y) } #define neg(x) (sub(INT2FIX(0), (x))) -#define cmp(x,y) (rb_cmpint(rb_funcall((x), id_cmp, 1, (y)), (x), (y))) #define lshift(x,y) (rb_funcall((x), id_lshift, 1, (y))) static VALUE @@ -3210,12 +3211,12 @@ time_cmp(VALUE time1, VALUE time2) n = wcmp(tobj1->timew, tobj2->timew); } else { - VALUE cmp; + VALUE tmp; - cmp = rb_funcall(time2, rb_intern("<=>"), 1, time1); - if (NIL_P(cmp)) return Qnil; + tmp = rb_funcall(time2, rb_intern("<=>"), 1, time1); + if (NIL_P(tmp)) return Qnil; - n = -rb_cmpint(cmp, time1, time2); + n = -rb_cmpint(tmp, time1, time2); } if (n == 0) return INT2FIX(0); if (n > 0) return INT2FIX(1); |