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

ruby-changes:40027

From: nobu <ko1@a...>
Date: Mon, 12 Oct 2015 09:09:02 +0900 (JST)
Subject: [ruby-changes:40027] nobu:r52108 (trunk): numeric.c: common expressions

nobu	2015-10-12 09:08:44 +0900 (Mon, 12 Oct 2015)

  New Revision: 52108

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

  Log:
    numeric.c: common expressions
    
    * numeric.c (flo_pow): extract common expressions.

  Modified files:
    trunk/numeric.c
Index: numeric.c
===================================================================
--- numeric.c	(revision 52107)
+++ numeric.c	(revision 52108)
@@ -1073,24 +1073,25 @@ flo_divmod(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1073
 static VALUE
 flo_pow(VALUE x, VALUE y)
 {
+    double dx, dy;
     if (RB_TYPE_P(y, T_FIXNUM)) {
-	return DBL2NUM(pow(RFLOAT_VALUE(x), (double)FIX2LONG(y)));
+	dx = RFLOAT_VALUE(x);
+	dy = (double)FIX2LONG(y);
     }
     else if (RB_TYPE_P(y, T_BIGNUM)) {
-	return DBL2NUM(pow(RFLOAT_VALUE(x), rb_big2dbl(y)));
+	dx = RFLOAT_VALUE(x);
+	dy = rb_big2dbl(y);
     }
     else if (RB_TYPE_P(y, T_FLOAT)) {
-	{
-	    double dx = RFLOAT_VALUE(x);
-	    double dy = RFLOAT_VALUE(y);
-	    if (dx < 0 && dy != round(dy))
-		return rb_funcall(rb_complex_raw1(x), rb_intern("**"), 1, y);
-	    return DBL2NUM(pow(dx, dy));
-	}
+	dx = RFLOAT_VALUE(x);
+	dy = RFLOAT_VALUE(y);
+	if (dx < 0 && dy != round(dy))
+	    return rb_funcall(rb_complex_raw1(x), rb_intern("**"), 1, y);
     }
     else {
 	return rb_num_coerce_bin(x, y, rb_intern("**"));
     }
+    return DBL2NUM(pow(dx, dy));
 }
 
 /*

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

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