mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
use mrb_int_mul_overflow()
This commit is contained in:
@@ -1862,25 +1862,15 @@ RETRY_TRY_BLOCK:
|
||||
switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {
|
||||
case TYPES2(MRB_TT_FIXNUM,MRB_TT_FIXNUM):
|
||||
{
|
||||
mrb_value z;
|
||||
mrb_int x, y, z;
|
||||
|
||||
z = mrb_fixnum_mul(mrb, regs[a], regs[a+1]);
|
||||
|
||||
switch (mrb_type(z)) {
|
||||
case MRB_TT_FIXNUM:
|
||||
{
|
||||
SET_INT_VALUE(regs[a], mrb_fixnum(z));
|
||||
}
|
||||
break;
|
||||
case MRB_TT_FLOAT:
|
||||
{
|
||||
SET_FLOAT_VALUE(mrb, regs[a], mrb_float(z));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* cannot happen */
|
||||
x = mrb_fixnum(regs[a]);
|
||||
y = mrb_fixnum(regs[a+1]);
|
||||
if (mrb_int_mul_overflow(x, y, &z)) {
|
||||
SET_FLOAT_VALUE(mrb, regs[a], (mrb_float)x * (mrb_float)y);
|
||||
break;
|
||||
}
|
||||
SET_INT_VALUE(regs[a], z);
|
||||
}
|
||||
break;
|
||||
case TYPES2(MRB_TT_FIXNUM,MRB_TT_FLOAT):
|
||||
|
||||
Reference in New Issue
Block a user