зеркало из https://github.com/github/ruby.git
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:
Родитель
0913d67f5d
Коммит
a5160c5051
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче