ruby-changes:44676
From: mrkn <ko1@a...>
Date: Sat, 12 Nov 2016 20:51:55 +0900 (JST)
Subject: [ruby-changes:44676] mrkn:r56749 (trunk): rational.c: optimize Float#{numerator, denominator}
mrkn 2016-11-12 20:51:51 +0900 (Sat, 12 Nov 2016) New Revision: 56749 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56749 Log: rational.c: optimize Float#{numerator,denominator} * rational.c (float_{numerator,denominator}): optimize Float#{numerator,denominator}. Author: Tadashi Saito <tad.a.digger@g...> Modified files: trunk/rational.c Index: rational.c =================================================================== --- rational.c (revision 56748) +++ rational.c (revision 56749) @@ -1924,6 +1924,7 @@ integer_denominator(VALUE self) https://github.com/ruby/ruby/blob/trunk/rational.c#L1924 return INT2FIX(1); } +static VALUE float_to_r(VALUE self); /* * call-seq: * flo.numerator -> integer @@ -1940,7 +1941,7 @@ float_numerator(VALUE self) https://github.com/ruby/ruby/blob/trunk/rational.c#L1941 double d = RFLOAT_VALUE(self); if (isinf(d) || isnan(d)) return self; - return rb_call_super(0, 0); + return nurat_numerator(float_to_r(self)); } /* @@ -1958,7 +1959,7 @@ float_denominator(VALUE self) https://github.com/ruby/ruby/blob/trunk/rational.c#L1959 double d = RFLOAT_VALUE(self); if (isinf(d) || isnan(d)) return INT2FIX(1); - return rb_call_super(0, 0); + return nurat_denominator(float_to_r(self)); } /* -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/