зеркало из https://github.com/github/ruby.git
Use FIX2LONG to avoid unexpected exception
Though it won't happen in the real world in this context, FIX2INT may raise an exception and it cause to generate extra code.
This commit is contained in:
Родитель
d45a013a1a
Коммит
26843cbcd0
|
@ -1461,7 +1461,7 @@ flo_cmp(VALUE x, VALUE y)
|
||||||
if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) {
|
if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) {
|
||||||
VALUE rel = rb_integer_float_cmp(y, x);
|
VALUE rel = rb_integer_float_cmp(y, x);
|
||||||
if (FIXNUM_P(rel))
|
if (FIXNUM_P(rel))
|
||||||
return INT2FIX(-FIX2INT(rel));
|
return LONG2FIX(-FIX2LONG(rel));
|
||||||
return rel;
|
return rel;
|
||||||
}
|
}
|
||||||
else if (RB_TYPE_P(y, T_FLOAT)) {
|
else if (RB_TYPE_P(y, T_FLOAT)) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче