summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-04 00:45:02 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-04 00:45:02 +0000
commit9c50406bd5892c95d76e966c1db8b85c4b5fbe32 (patch)
tree986bf6d2b081bd36ad3843c0cefd928fc38c66da /time.c
parenteb71e5cd67f4ce4da5ba331f93a8e36c65457b94 (diff)
* 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.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/time.c b/time.c
index 5d310508fb..6c42c4d802 100644
--- a/time.c
+++ b/time.c
@@ -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);