From a5160c50511db1e62316225ca13cc075679250b1 Mon Sep 17 00:00:00 2001 From: mrkn Date: Sat, 12 Nov 2016 06:17:12 +0000 Subject: [PATCH] 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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- rational.c | 4 ++-- 1 file 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);