diff options
author | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-11 16:17:56 +0000 |
---|---|---|
committer | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-11 16:17:56 +0000 |
commit | bc4310718bc6bef6fd24fe273fe18c66387b8eb8 (patch) | |
tree | a728802988e59b78c2e589fee7468e2122a953a4 /rational.c | |
parent | 06d701a1f0c5981a386458c55cccef9486819cb5 (diff) |
rational.c: optimize Rational#/
* rational.c (f_muldiv, nurat_div): optimize Rational#/.
Author: Tadashi Saito <[email protected]>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'rational.c')
-rw-r--r-- | rational.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/rational.c b/rational.c index 44a720aebe..8a952f6b68 100644 --- a/rational.c +++ b/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(); |