mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
rational.c: optimize Float#{numerator,denominator}
* rational.c (float_{numerator,denominator}): optimize Float#{numerator,denominator}. Author: Tadashi Saito <tad.a.digger@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ea5b76a079
commit
ffa2b0061f
1 changed files with 3 additions and 2 deletions
|
@ -1924,6 +1924,7 @@ integer_denominator(VALUE self)
|
|||
return INT2FIX(1);
|
||||
}
|
||||
|
||||
static VALUE float_to_r(VALUE self);
|
||||
/*
|
||||
* call-seq:
|
||||
* flo.numerator -> integer
|
||||
|
@ -1940,7 +1941,7 @@ float_numerator(VALUE self)
|
|||
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)
|
|||
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));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue