aboutsummaryrefslogtreecommitdiffstats
path: root/rational.c
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-12 06:17:12 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-12 06:17:12 +0000
commit802bfba19c02058e95a31194c9316680df0c15e1 (patch)
tree5c4cbd74b731f9a7c59b1b9d1df71742e20ed856 /rational.c
parent6c42b0b9e7f3b1d6cfa925fba8ce2d832aeac0f1 (diff)
downloadruby-802bfba19c02058e95a31194c9316680df0c15e1.tar.gz
rational.c: optimize rational.coerce(float) and float [+-*/] rational
* rational.c (nurat_coerce): optimize rational.coerce(float). note that this makes `float [+-*/] rational` faster Author: Tadashi Saito <tad.a.digger@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'rational.c')
-rw-r--r--rational.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/rational.c b/rational.c
index 7652ffa0d7..c55081a143 100644
--- a/rational.c
+++ b/rational.c
@@ -1158,8 +1158,8 @@ nurat_coerce(VALUE self, VALUE other)
if (RB_INTEGER_TYPE_P(other)) {
return rb_assoc_new(f_rational_new_bang1(CLASS_OF(self), other), self);
}
- else if (RB_TYPE_P(other, T_FLOAT)) {
- return rb_assoc_new(other, f_to_f(self));
+ else if (RB_FLOAT_TYPE_P(other)) {
+ return rb_assoc_new(other, nurat_to_f(self));
}
else if (RB_TYPE_P(other, T_RATIONAL)) {
return rb_assoc_new(other, self);