mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
rational.c: optimize Rational#/
* rational.c (f_muldiv, nurat_div): optimize Rational#/. Author: Tadashi Saito <tad.a.digger@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
06d701a1f0
commit
bc4310718b
1 changed files with 5 additions and 5 deletions
10
rational.c
10
rational.c
|
@ -812,9 +812,9 @@ f_muldiv(VALUE self, VALUE anum, VALUE aden, VALUE bnum, VALUE bden, int k)
|
|||
if (k == '/') {
|
||||
VALUE t;
|
||||
|
||||
if (f_negative_p(bnum)) {
|
||||
anum = f_negate(anum);
|
||||
bnum = f_negate(bnum);
|
||||
if (INT_NEGATIVE_P(bnum)) {
|
||||
anum = rb_int_uminus(anum);
|
||||
bnum = rb_int_uminus(bnum);
|
||||
}
|
||||
t = bnum;
|
||||
bnum = bden;
|
||||
|
@ -911,8 +911,8 @@ nurat_div(VALUE self, VALUE other)
|
|||
other, ONE, '/');
|
||||
}
|
||||
}
|
||||
else if (RB_TYPE_P(other, T_FLOAT))
|
||||
return rb_funcall(f_to_f(self), '/', 1, other);
|
||||
else if (RB_FLOAT_TYPE_P(other))
|
||||
return DBL2NUM(nurat_to_double(self) / RFLOAT_VALUE(other));
|
||||
else if (RB_TYPE_P(other, T_RATIONAL)) {
|
||||
if (f_zero_p(other))
|
||||
rb_raise_zerodiv();
|
||||
|
|
Loading…
Reference in a new issue