зеркало из https://github.com/github/ruby.git
rational.c: optimize rational * {float, huge rational, bignum}
* rational.c (f_muldiv, nurat_mul): optimize rational * {float, huge rational, bignum}. Author: Tadashi Saito <tad.a.digger@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
86ec117881
Коммит
8fd00809a7
|
@ -837,8 +837,8 @@ f_muldiv(VALUE self, VALUE anum, VALUE aden, VALUE bnum, VALUE bden, int k)
|
|||
VALUE g1 = f_gcd(anum, bden);
|
||||
VALUE g2 = f_gcd(aden, bnum);
|
||||
|
||||
num = f_mul(f_idiv(anum, g1), f_idiv(bnum, g2));
|
||||
den = f_mul(f_idiv(aden, g2), f_idiv(bden, g1));
|
||||
num = rb_int_mul(rb_int_idiv(anum, g1), rb_int_idiv(bnum, g2));
|
||||
den = rb_int_mul(rb_int_idiv(aden, g2), rb_int_idiv(bden, g1));
|
||||
}
|
||||
return f_rational_new_no_reduce2(CLASS_OF(self), num, den);
|
||||
}
|
||||
|
@ -867,8 +867,8 @@ nurat_mul(VALUE self, VALUE other)
|
|||
other, ONE, '*');
|
||||
}
|
||||
}
|
||||
else if (RB_TYPE_P(other, T_FLOAT)) {
|
||||
return f_mul(f_to_f(self), other);
|
||||
else if (RB_FLOAT_TYPE_P(other)) {
|
||||
return DBL2NUM(RFLOAT_VALUE(nurat_to_f(self)) * RFLOAT_VALUE(other));
|
||||
}
|
||||
else if (RB_TYPE_P(other, T_RATIONAL)) {
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче