mruby-bigint (mrb_bint_new_float): add fast path for FIXABLE_FLOAT

This commit is contained in:
Yukihiro "Matz" Matsumoto
2024-08-14 16:11:27 +09:00
parent 92302df49d
commit 6e5a493ff3
+4
View File
@@ -1151,6 +1151,10 @@ mrb_bint_new_float(mrb_state *mrb, mrb_float x)
/* x should not be NaN nor Infinity */
mrb_assert(x == x && x != x * 0.5);
if (FIXABLE_FLOAT(x)) {
return mrb_int_value(mrb, (mrb_int)x);
}
int sn;
if (x < 0.0) {
x = -x;