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

ruby-changes:44632

From: mrkn <ko1@a...>
Date: Fri, 11 Nov 2016 23:39:10 +0900 (JST)
Subject: [ruby-changes:44632] mrkn:r56705 (trunk): rational.c: optimize rational + integer.

mrkn	2016-11-11 23:39:07 +0900 (Fri, 11 Nov 2016)

  New Revision: 56705

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

  Log:
    rational.c: optimize rational + integer.
    
    * rational.c (rb_rational_plus): optimize rational + integer.
      Author: Tadashi Saito <tad.a.digger@g...>

  Modified files:
    trunk/rational.c
Index: rational.c
===================================================================
--- rational.c	(revision 56704)
+++ rational.c	(revision 56705)
@@ -735,9 +735,9 @@ rb_rational_plus(VALUE self, VALUE other https://github.com/ruby/ruby/blob/trunk/rational.c#L735
 	{
 	    get_dat1(self);
 
-	    return f_addsub(self,
-			    dat->num, dat->den,
-			    other, ONE, '+');
+	    return f_rational_new_no_reduce2(CLASS_OF(self),
+					     rb_int_plus(dat->num, rb_int_mul(other, dat->den)),
+					     dat->den);
 	}
     }
     else if (RB_TYPE_P(other, T_FLOAT)) {

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

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