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

ruby-changes:37771

From: gogotanaka <ko1@a...>
Date: Thu, 5 Mar 2015 12:29:50 +0900 (JST)
Subject: [ruby-changes:37771] gogotanaka:r49852 (trunk): * math.c: refactoring: remove unnecessary variable d0 to unify code

gogotanaka	2015-03-05 12:29:37 +0900 (Thu, 05 Mar 2015)

  New Revision: 49852

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

  Log:
    * math.c: refactoring: remove unnecessary variable d0 to unify code
      appearance.

  Modified files:
    trunk/ChangeLog
    trunk/math.c
Index: math.c
===================================================================
--- math.c	(revision 49851)
+++ math.c	(revision 49852)
@@ -216,13 +216,12 @@ math_tan(VALUE obj, VALUE x) https://github.com/ruby/ruby/blob/trunk/math.c#L216
 static VALUE
 math_acos(VALUE obj, VALUE x)
 {
-    double d0, d;
+    double d;
 
-    d0 = Get_Double(x);
+    d = Get_Double(x);
     /* check for domain error */
-    if (d0 < -1.0 || 1.0 < d0) domain_error("acos");
-    d = acos(d0);
-    return DBL2NUM(d);
+    if (d < -1.0 || 1.0 < d) domain_error("acos");
+    return DBL2NUM(acos(d));
 }
 
 /*
@@ -241,13 +240,12 @@ math_acos(VALUE obj, VALUE x) https://github.com/ruby/ruby/blob/trunk/math.c#L240
 static VALUE
 math_asin(VALUE obj, VALUE x)
 {
-    double d0, d;
+    double d;
 
-    d0 = Get_Double(x);
+    d = Get_Double(x);
     /* check for domain error */
-    if (d0 < -1.0 || 1.0 < d0) domain_error("asin");
-    d = asin(d0);
-    return DBL2NUM(d);
+    if (d < -1.0 || 1.0 < d) domain_error("asin");
+    return DBL2NUM(asin(d));
 }
 
 /*
@@ -370,13 +368,12 @@ math_tanh(VALUE obj, VALUE x) https://github.com/ruby/ruby/blob/trunk/math.c#L368
 static VALUE
 math_acosh(VALUE obj, VALUE x)
 {
-    double d0, d;
+    double d;
 
-    d0 = Get_Double(x);
+    d = Get_Double(x);
     /* check for domain error */
-    if (d0 < 1.0) domain_error("acosh");
-    d = acosh(d0);
-    return DBL2NUM(d);
+    if (d < 1.0) domain_error("acosh");
+    return DBL2NUM(acosh(d));
 }
 
 /*
@@ -416,16 +413,15 @@ math_asinh(VALUE obj, VALUE x) https://github.com/ruby/ruby/blob/trunk/math.c#L413
 static VALUE
 math_atanh(VALUE obj, VALUE x)
 {
-    double d0, d;
+    double d;
 
-    d0 = Get_Double(x);
+    d = Get_Double(x);
     /* check for domain error */
-    if (d0 <  -1.0 || +1.0 <  d0) domain_error("atanh");
+    if (d <  -1.0 || +1.0 <  d) domain_error("atanh");
     /* check for pole error */
-    if (d0 == -1.0) return DBL2NUM(-INFINITY);
-    if (d0 == +1.0) return DBL2NUM(+INFINITY);
-    d = atanh(d0);
-    return DBL2NUM(d);
+    if (d == -1.0) return DBL2NUM(-INFINITY);
+    if (d == +1.0) return DBL2NUM(+INFINITY);
+    return DBL2NUM(atanh(d));
 }
 
 /*
@@ -647,14 +643,13 @@ math_log10(VALUE obj, VALUE x) https://github.com/ruby/ruby/blob/trunk/math.c#L643
 static VALUE
 math_sqrt(VALUE obj, VALUE x)
 {
-    double d0, d;
+    double d;
 
-    d0 = Get_Double(x);
+    d = Get_Double(x);
     /* check for domain error */
-    if (d0 < 0.0) domain_error("sqrt");
-    if (d0 == 0.0) return DBL2NUM(0.0);
-    d = sqrt(d0);
-    return DBL2NUM(d);
+    if (d < 0.0) domain_error("sqrt");
+    if (d == 0.0) return DBL2NUM(0.0);
+    return DBL2NUM(sqrt(d));
 }
 
 /*
@@ -862,12 +857,12 @@ math_gamma(VALUE obj, VALUE x) https://github.com/ruby/ruby/blob/trunk/math.c#L857
          * impossible to represent exactly in IEEE 754 double which have
          * 53bit mantissa. */
     };
-    double d0, d;
+    double d;
     double intpart, fracpart;
-    d0 = Get_Double(x);
+    d = Get_Double(x);
     /* check for domain error */
-    if (isinf(d0) && signbit(d0)) domain_error("gamma");
-    fracpart = modf(d0, &intpart);
+    if (isinf(d) && signbit(d)) domain_error("gamma");
+    fracpart = modf(d, &intpart);
     if (fracpart == 0.0) {
 	if (intpart < 0) domain_error("gamma");
 	if (0 < intpart &&
@@ -875,8 +870,7 @@ math_gamma(VALUE obj, VALUE x) https://github.com/ruby/ruby/blob/trunk/math.c#L870
 	    return DBL2NUM(fact_table[(int)intpart - 1]);
 	}
     }
-    d = tgamma(d0);
-    return DBL2NUM(d);
+    return DBL2NUM(tgamma(d));
 }
 
 /*
@@ -896,17 +890,16 @@ math_gamma(VALUE obj, VALUE x) https://github.com/ruby/ruby/blob/trunk/math.c#L890
 static VALUE
 math_lgamma(VALUE obj, VALUE x)
 {
-    double d0, d;
+    double d;
     int sign=1;
     VALUE v;
-    d0 = Get_Double(x);
+    d = Get_Double(x);
     /* check for domain error */
-    if (isinf(d0)) {
-	if (signbit(d0)) domain_error("lgamma");
+    if (isinf(d)) {
+	if (signbit(d)) domain_error("lgamma");
 	return rb_assoc_new(DBL2NUM(INFINITY), INT2FIX(1));
     }
-    d = lgamma_r(d0, &sign);
-    v = DBL2NUM(d);
+    v = DBL2NUM(lgamma_r(d, &sign));
     return rb_assoc_new(v, INT2FIX(sign));
 }
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49851)
+++ ChangeLog	(revision 49852)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Mar  5 12:22:23 2015  Kazuki Tanaka  <gogotanaka@r...>
+
+	* math.c: refactoring: remove unnecessary variable d0 to unify code
+	  appearance.
+
 Thu Mar  5 11:50:54 2015  Shugo Maeda  <shugo@r...>
 
 	* vm_eval.c (eval_string_with_cref): A binding should keep
@@ -254,7 +259,7 @@ Tue Feb 24 22:58:48 2015  Nobuyoshi Naka https://github.com/ruby/ruby/blob/trunk/ChangeLog#L259
 	* complex.c (nucomp_mul): calculate as rotation in complex plane
 	  if matrix calculation resulted in NaN.
 
-Tue Feb 24 21:45:39 2015  Kazuki Tanaka  <mail@t...>
+Tue Feb 24 21:45:39 2015  Kazuki Tanaka  <gogotanaka@r...>
 
 	* test/ruby/test_math.rb(test_cbrt): Add an assertion for Math.cbrt(1.0/0)
 	  and move #test_cbrt to more proper place.
@@ -715,7 +720,7 @@ Sat Jan 31 12:06:23 2015  Scott Francis https://github.com/ruby/ruby/blob/trunk/ChangeLog#L720
 	  start up so that it will not clash with the heap space.
 	  [Fix GH-822]
 
-Fri Jan 30 17:28:29 2015  gogotanaka  <mail@t...>
+Fri Jan 30 17:28:29 2015  Kazuki Tanaka  <gogotanaka@r...>
 
 	* math.c (num2dbl_with_to_f): make faster when Bignum passed by
 	  direct conversion using rb_big2dbl().  [Feature #10800]
@@ -736,7 +741,7 @@ Thu Jan 29 20:28:25 2015  SHIBATA Hirosh https://github.com/ruby/ruby/blob/trunk/ChangeLog#L741
 
 	* tool/make-snapshot: removed md5 digest with package information
 
-Thu Jan 29 10:41:52 2015  gogotanaka  <mail@t...>
+Thu Jan 29 10:41:52 2015  Kazuki Tanaka  <gogotanaka@r...>
 
 	* math.c (Get_Double): direct casting from Fixnum to double.
 	  [Feature #10785]

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

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