summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-11 15:11:04 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-11 15:11:04 +0000
commit8fd00809a77bf505f6760c23c60e45a205f514a5 (patch)
tree05bf32e3886e6c03ec5aa6ba20530e7836545cc6
parent86ec1178810b3a2d9a9a015108b5a2b42651d1fa (diff)
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
-rw-r--r--rational.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/rational.c b/rational.c
index e4f737bbbe..2ba501b4a2 100644
--- a/rational.c
+++ b/rational.c
@@ -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)) {
{