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

ruby-changes:45158

From: nobu <ko1@a...>
Date: Thu, 29 Dec 2016 18:06:06 +0900 (JST)
Subject: [ruby-changes:45158] nobu:r57230 (trunk): rational.c: canonicalization

nobu	2016-12-29 18:05:59 +0900 (Thu, 29 Dec 2016)

  New Revision: 57230

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

  Log:
    rational.c: canonicalization
    
    * rational.c (canonicalization): define always regardless CANON,
      and remove unnecessary ifdefs.

  Modified files:
    trunk/rational.c
Index: rational.c
===================================================================
--- rational.c	(revision 57229)
+++ rational.c	(revision 57230)
@@ -445,6 +445,8 @@ nurat_canonicalization(int f) https://github.com/ruby/ruby/blob/trunk/rational.c#L445
 {
     canonicalization = f;
 }
+#else
+# define canonicalization 0
 #endif
 
 inline static void
@@ -489,10 +491,8 @@ nurat_s_canonicalize_internal(VALUE klas https://github.com/ruby/ruby/blob/trunk/rational.c#L491
     num = f_idiv(num, gcd);
     den = f_idiv(den, gcd);
 
-#ifdef CANON
-    if (f_one_p(den) && canonicalization)
+    if (canonicalization && f_one_p(den))
 	return num;
-#endif
     return nurat_s_new_internal(klass, num, den);
 }
 
@@ -501,10 +501,8 @@ nurat_s_canonicalize_internal_no_reduce( https://github.com/ruby/ruby/blob/trunk/rational.c#L501
 {
     nurat_canonicalize(&num, &den);
 
-#ifdef CANON
-    if (f_one_p(den) && canonicalization)
+    if (canonicalization && f_one_p(den))
 	return num;
-#endif
     return nurat_s_new_internal(klass, num, den);
 }
 
@@ -1957,13 +1955,10 @@ numeric_quo(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/rational.c#L1955
         return rb_funcall(x, rb_intern("fdiv"), 1, y);
     }
 
-#ifdef CANON
     if (canonicalization) {
         x = rb_rational_raw1(x);
     }
-    else
-#endif
-    {
+    else {
         x = rb_convert_type(x, T_RATIONAL, "Rational", "to_r");
     }
     return nurat_div(x, y);
@@ -2338,14 +2333,12 @@ read_num(const char **s, int numsign, in https://github.com/ruby/ruby/blob/trunk/rational.c#L2333
 	    return 0;
 	{
 	    VALUE l = f_expt10(INT2NUM(count));
-#ifdef CANON
 	    if (canonicalization) {
 		*num = rb_int_mul(*num, l);
 		*num = rb_int_plus(*num, fp);
 		*num = rb_rational_new2(*num, l);
 	    }
 	    else
-#endif
 	    {
 		*num = nurat_mul(*num, l);
 		*num = rb_rational_plus(*num, fp);

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

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