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
This commit is contained in:
mrkn 2016-11-12 06:17:12 +00:00
Родитель 0913d67f5d
Коммит a5160c5051
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -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);