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

ruby-changes:44666

From: mrkn <ko1@a...>
Date: Sat, 12 Nov 2016 15:17:16 +0900 (JST)
Subject: [ruby-changes:44666] mrkn:r56741 (trunk): rational.c: optimize rational.coerce(float) and float [+-*/] rational

mrkn	2016-11-12 15:17:12 +0900 (Sat, 12 Nov 2016)

  New Revision: 56741

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

  Log:
    rational.c: optimize rational.coerce(float) and float [+-*/] rational
    
    * rational.c (nurat_coerce): optimize rational.coerce(float).
      note that this makes `float [+-*/] rational` faster
      Author: Tadashi Saito <tad.a.digger@g...>

  Modified files:
    trunk/rational.c
Index: rational.c
===================================================================
--- rational.c	(revision 56740)
+++ rational.c	(revision 56741)
@@ -1158,8 +1158,8 @@ nurat_coerce(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/rational.c#L1158
     if (RB_INTEGER_TYPE_P(other)) {
 	return rb_assoc_new(f_rational_new_bang1(CLASS_OF(self), other), self);
     }
-    else if (RB_TYPE_P(other, T_FLOAT)) {
-	return rb_assoc_new(other, f_to_f(self));
+    else if (RB_FLOAT_TYPE_P(other)) {
+        return rb_assoc_new(other, nurat_to_f(self));
     }
     else if (RB_TYPE_P(other, T_RATIONAL)) {
 	return rb_assoc_new(other, self);

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

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