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

ruby-changes:44697

From: mrkn <ko1@a...>
Date: Mon, 14 Nov 2016 01:22:13 +0900 (JST)
Subject: [ruby-changes:44697] mrkn:r56770 (trunk): complex.c: refactoring and small optimization

mrkn	2016-11-14 01:22:08 +0900 (Mon, 14 Nov 2016)

  New Revision: 56770

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

  Log:
    complex.c: refactoring and small optimization
    
    * complex.c (nucomp_expt): optimize the access to the numerator and
      denominator of a rational number.
    
    * complex.c (k_rational_p): removed.

  Modified files:
    trunk/complex.c
Index: complex.c
===================================================================
--- complex.c	(revision 56769)
+++ complex.c	(revision 56770)
@@ -237,12 +237,6 @@ k_numeric_p(VALUE x) https://github.com/ruby/ruby/blob/trunk/complex.c#L237
     return f_kind_of_p(x, rb_cNumeric);
 }
 
-
-inline static VALUE
-k_rational_p(VALUE x)
-{
-    return f_kind_of_p(x, rb_cRational);
-}
 #define k_exact_p(x) (!RB_FLOAT_TYPE_P(x))
 
 #define k_exact_zero_p(x) (k_exact_p(x) && f_zero_p(x))
@@ -895,8 +889,8 @@ nucomp_expt(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/complex.c#L889
     if (k_numeric_p(other) && k_exact_zero_p(other))
 	return f_complex_new_bang1(CLASS_OF(self), ONE);
 
-    if (k_rational_p(other) && f_one_p(f_denominator(other)))
-	other = f_numerator(other); /* c14n */
+    if (RB_TYPE_P(other, T_RATIONAL) && RRATIONAL(other)->den == LONG2FIX(1))
+	other = RRATIONAL(other)->num; /* c14n */
 
     if (RB_TYPE_P(other, T_COMPLEX)) {
 	get_dat1(other);

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

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