* time.c (mul): condition refined.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d5c005fd36
commit
075cbd2ad6
@ -1,4 +1,8 @@
|
||||
2010-03-27 Tanaka Akira <akr@fsij.org>
|
||||
Sun Mar 28 07:12:41 2010 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* time.c (mul): condition refined.
|
||||
|
||||
Sun Mar 28 02:14:13 2010 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* time.c: fix previos commit.
|
||||
|
||||
|
12
time.c
12
time.c
@ -252,18 +252,22 @@ mul(VALUE x, VALUE y)
|
||||
if (FIXNUM_P(x) && FIXNUM_P(y)) {
|
||||
#if HAVE_LONG_LONG && SIZEOF_LONG * 2 <= SIZEOF_LONG_LONG
|
||||
LONG_LONG ll = (LONG_LONG)FIX2LONG(x) * FIX2LONG(y);
|
||||
if (FIXABLE(ll)) return LONG2FIX(ll);
|
||||
if (FIXABLE(ll))
|
||||
return LONG2FIX(ll);
|
||||
return LL2NUM(ll);
|
||||
#else
|
||||
long a, b, c;
|
||||
a = FIX2LONG(x);
|
||||
if (a == 0) return x;
|
||||
if (a == 0)
|
||||
return x;
|
||||
b = FIX2LONG(y);
|
||||
c = a * b;
|
||||
if (c / a == b && FIXABLE(c)) return LONG2FIX(c);
|
||||
if (c / a == b)
|
||||
return LONG2NUM(c);
|
||||
#endif
|
||||
}
|
||||
if (TYPE(x) == T_BIGNUM) return rb_big_mul(x, y);
|
||||
if (TYPE(x) == T_BIGNUM)
|
||||
return rb_big_mul(x, y);
|
||||
return rb_funcall(x, '*', 1, y);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user