[前][次][番号順一覧][スレッド一覧]

ruby-changes:42126

From: naruse <ko1@a...>
Date: Sun, 20 Mar 2016 18:47:28 +0900 (JST)
Subject: [ruby-changes:42126] naruse:r54200 (trunk): * time.c (add): remove FIXABLE() which is in LONG2NUM().

naruse	2016-03-20 18:47:20 +0900 (Sun, 20 Mar 2016)

  New Revision: 54200

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54200

  Log:
    * time.c (add): remove FIXABLE() which is in LONG2NUM().
    
    * time.c (sub): ditto.
    
    * time.c (mul): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/time.c
Index: time.c
===================================================================
--- time.c	(revision 54199)
+++ time.c	(revision 54200)
@@ -75,9 +75,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/time.c#L75
 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 https://github.com/ruby/ruby/blob/trunk/time.c#L85
 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) https://github.com/ruby/ruby/blob/trunk/time.c#L140
 {
     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))
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 54199)
+++ ChangeLog	(revision 54200)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Mar 20 18:44:52 2016  NARUSE, Yui  <naruse@r...>
+
+	* 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@r...>
 
 	* bignum.c (rb_big_cmp): reduce the code.

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]