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

ruby-changes:42164

From: mrkn <ko1@a...>
Date: Wed, 23 Mar 2016 21:50:29 +0900 (JST)
Subject: [ruby-changes:42164] mrkn:r54238 (trunk): * enum.c (ary_inject_op): put subtract operation out of if-clause.

mrkn	2016-03-23 21:50:24 +0900 (Wed, 23 Mar 2016)

  New Revision: 54238

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

  Log:
    * enum.c (ary_inject_op): put subtract operation out of if-clause.

  Modified files:
    trunk/ChangeLog
    trunk/enum.c
Index: enum.c
===================================================================
--- enum.c	(revision 54237)
+++ enum.c	(revision 54238)
@@ -688,17 +688,18 @@ ary_inject_op(VALUE ary, VALUE init, VAL https://github.com/ruby/ruby/blob/trunk/enum.c#L688
           sum_float:
             c = 0.0;
             while (1) {
-                double y, t;
+                double x, y, t;
                 e = RARRAY_AREF(ary, i);
                 if (RB_FLOAT_TYPE_P(e))
-                    y = RFLOAT_VALUE(e) - c;
+                    x = RFLOAT_VALUE(e);
                 else if (FIXNUM_P(e))
-                    y = FIX2LONG(e) - c;
+                    x = FIX2LONG(e);
                 else if (RB_TYPE_P(e, T_BIGNUM))
-                    y = rb_big2dbl(e) - c;
+                    x = rb_big2dbl(e);
                 else
                     break;
 
+                y = x - c;
                 t = f + y;
                 c = (t - f) - y;
                 f = t;
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 54237)
+++ ChangeLog	(revision 54238)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Mar 23 21:48:00 2016  Kenta Murata  <mrkn@m...>
+
+	* enum.c (ary_inject_op): put subtract operation out of if-clause.
+
 Wed Mar 23 21:38:00 2016  Kenta Murata  <mrkn@m...>
 
 	* enum.c (ary_inject_op): Use Kahan's compensated summation algorithm

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

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