ruby-changes:44670
From: mrkn <ko1@a...>
Date: Sat, 12 Nov 2016 15:58:40 +0900 (JST)
Subject: [ruby-changes:44670] mrkn:r56743 (trunk): rational.c: optimize Rational#to_i
mrkn 2016-11-12 15:58:35 +0900 (Sat, 12 Nov 2016) New Revision: 56743 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56743 Log: rational.c: optimize Rational#to_i * rational.c (nurat_truncate): optimize Rational#to_i. Author: Tadashi Saito <tad.a.digger@g...> Modified files: trunk/rational.c Index: rational.c =================================================================== --- rational.c (revision 56742) +++ rational.c (revision 56743) @@ -1243,9 +1243,9 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/rational.c#L1243 nurat_truncate(VALUE self) { get_dat1(self); - if (f_negative_p(dat->num)) - return f_negate(f_idiv(f_negate(dat->num), dat->den)); - return f_idiv(dat->num, dat->den); + if (INT_NEGATIVE_P(dat->num)) + return rb_int_uminus(rb_int_idiv(rb_int_uminus(dat->num), dat->den)); + return rb_int_idiv(dat->num, dat->den); } static VALUE -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/