ruby-changes:44635
From: mrkn <ko1@a...>
Date: Fri, 11 Nov 2016 23:45:15 +0900 (JST)
Subject: [ruby-changes:44635] mrkn:r56710 (trunk): rational.c: optimize rational - integer
mrkn 2016-11-11 23:45:11 +0900 (Fri, 11 Nov 2016) New Revision: 56710 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56710 Log: rational.c: optimize rational - integer * rational.c (nurat_sub): optimize rational - integer. Author: Tadashi Saito <tad.a.digger@g...> Modified files: trunk/rational.c Index: rational.c =================================================================== --- rational.c (revision 56709) +++ rational.c (revision 56710) @@ -782,9 +782,9 @@ nurat_sub(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/rational.c#L782 { get_dat1(self); - return f_addsub(self, - dat->num, dat->den, - other, ONE, '-'); + return f_rational_new_no_reduce2(CLASS_OF(self), + rb_int_minus(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/