diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-20 09:47:20 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-20 09:47:20 +0000 |
commit | 86a4ef44e954126825adc49ee40d22f165f5d831 (patch) | |
tree | b0db26e71737773a1f970778847adba159a1c5e9 | |
parent | c86bbd91245420d0d5b04abf6c7e70edc40fc9b0 (diff) | |
download | ruby-86a4ef44e954126825adc49ee40d22f165f5d831.tar.gz |
* time.c (add): remove FIXABLE() which is in LONG2NUM().
* time.c (sub): ditto.
* time.c (mul): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | time.c | 13 |
2 files changed, 11 insertions, 10 deletions
@@ -1,3 +1,11 @@ +Sun Mar 20 18:44:52 2016 NARUSE, Yui <naruse@ruby-lang.org> + + * time.c (add): remove FIXABLE() which is in LONG2NUM(). + + * time.c (sub): ditto. + + * time.c (mul): ditto. + Sun Mar 20 04:46:02 2016 NARUSE, Yui <naruse@ruby-lang.org> * bignum.c (rb_big_cmp): reduce the code. @@ -75,9 +75,7 @@ static VALUE add(VALUE x, VALUE y) { if (FIXNUM_P(x) && FIXNUM_P(y)) { - long l = FIX2LONG(x) + FIX2LONG(y); - if (FIXABLE(l)) return LONG2FIX(l); - return LONG2NUM(l); + return LONG2NUM(FIX2LONG(x) + FIX2LONG(y)); } if (RB_TYPE_P(x, T_BIGNUM)) return rb_big_plus(x, y); return rb_funcall(x, '+', 1, y); @@ -87,9 +85,7 @@ static VALUE sub(VALUE x, VALUE y) { if (FIXNUM_P(x) && FIXNUM_P(y)) { - long l = FIX2LONG(x) - FIX2LONG(y); - if (FIXABLE(l)) return LONG2FIX(l); - return LONG2NUM(l); + return LONG2NUM(FIX2LONG(x) - FIX2LONG(y)); } if (RB_TYPE_P(x, T_BIGNUM)) return rb_big_minus(x, y); return rb_funcall(x, '-', 1, y); @@ -144,10 +140,7 @@ 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); - return LL2NUM(ll); + return LL2NUM((LONG_LONG)FIX2LONG(x) * FIX2LONG(y)); #else long z; if (long_mul(FIX2LONG(x), FIX2LONG(y), &z)) |