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

ruby-changes:44682

From: mrkn <ko1@a...>
Date: Sat, 12 Nov 2016 23:54:26 +0900 (JST)
Subject: [ruby-changes:44682] mrkn:r56755 (trunk): rational.c: refactoring

mrkn	2016-11-12 23:54:19 +0900 (Sat, 12 Nov 2016)

  New Revision: 56755

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

  Log:
    rational.c: refactoring
    
    * rational.c (id_expt, id_fdiv, f_expt, f_fdiv, f_positive_p): removed.
      Author: Tadashi Saito <tad.a.digger@g...>

  Modified files:
    trunk/rational.c
Index: rational.c
===================================================================
--- rational.c	(revision 56754)
+++ rational.c	(revision 56755)
@@ -33,9 +33,8 @@ https://github.com/ruby/ruby/blob/trunk/rational.c#L33
 
 VALUE rb_cRational;
 
-static ID id_abs, id_eqeq_p, id_expt, id_fdiv,
-    id_idiv, id_integer_p, id_negate,
-    id_to_i, id_i_num, id_i_den;
+static ID id_abs, id_eqeq_p, id_idiv, id_integer_p, id_negate, id_to_i,
+    id_i_num, id_i_den;
 
 #define f_boolcast(x) ((x) ? Qtrue : Qfalse)
 #define f_inspect rb_inspect
@@ -145,11 +144,6 @@ f_eqeq_p(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/rational.c#L144
     return RTEST(rb_funcall(x, id_eqeq_p, 1, y));
 }
 
-#if FLT_RADIX != 2
-fun2(expt)
-#endif
-
-fun2(fdiv)
 fun2(idiv)
 
 #define f_expt10(x) rb_int_pow(INT2FIX(10), x)
@@ -160,8 +154,6 @@ f_negative_p(VALUE x) https://github.com/ruby/ruby/blob/trunk/rational.c#L154
     return rb_num_negative_p(x);
 }
 
-#define f_positive_p(x) (!f_negative_p(x))
-
 inline static int
 f_zero_p(VALUE x)
 {
@@ -1046,7 +1038,7 @@ nurat_expt(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/rational.c#L1038
 	return rb_float_pow(nurat_to_f(self), other);
     }
     else {
-	return rb_num_coerce_bin(self, other, id_expt);
+	return rb_num_coerce_bin(self, other, rb_intern("**"));
     }
 }
 
@@ -1882,7 +1874,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/rational.c#L1874
 numeric_quo(VALUE x, VALUE y)
 {
     if (RB_TYPE_P(y, T_FLOAT)) {
-        return f_fdiv(x, y);
+        return rb_funcall(x, rb_intern("fdiv"), 1, y);
     }
 
 #ifdef CANON
@@ -2570,8 +2562,6 @@ Init_Rational(void) https://github.com/ruby/ruby/blob/trunk/rational.c#L2562
 
     id_abs = rb_intern("abs");
     id_eqeq_p = rb_intern("==");
-    id_expt = rb_intern("**");
-    id_fdiv = rb_intern("fdiv");
     id_idiv = rb_intern("div");
     id_integer_p = rb_intern("integer?");
     id_negate = rb_intern("-@");

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

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