numeric.c (cmpnum): skip mrb_as_float() if possible

This commit is contained in:
Yukihiro "Matz" Matsumoto
2024-06-27 10:02:06 +09:00
parent 5b27469d19
commit f709847bde
+6 -1
View File
@@ -1922,8 +1922,13 @@ cmpnum(mrb_state *mrb, mrb_value v1, mrb_value v2)
#ifdef MRB_USE_BIGINT
case MRB_TT_BIGINT:
#endif
case MRB_TT_FLOAT:
case MRB_TT_INTEGER:
if (mrb_fixnum_p(v2)) {
y = (mrb_float)mrb_integer(v2);
break;
}
/* fall through */
case MRB_TT_FLOAT:
y = mrb_as_float(mrb, v2);
break;
default: