diff options
author | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-12 06:17:12 +0000 |
---|---|---|
committer | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-12 06:17:12 +0000 |
commit | a5160c50511db1e62316225ca13cc075679250b1 (patch) | |
tree | 5c4cbd74b731f9a7c59b1b9d1df71742e20ed856 /rational.c | |
parent | 0913d67f5d626322a4c0bf7eed4d03d59cdbf85c (diff) |
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.c | 4 |
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); |