complex.c: use `mrb_num_div_flo` to avoid copying function.
This change relies that `mrb_num_div_flo` does not use `mrb` inside.
MODIFY
mrbgems/mruby-complex/src/complex.c
mrbgems/mruby-complex/src/complex.c
@@ -235,19 +235,10 @@ complex_mul(mrb_state *mrb, mrb_value x)
}
}
-mrb_float
-div_flo(mrb_float x, mrb_float y)
-{
- if (y != 0.0) {
- return x / y;
- }
- else if (x == 0.0) {
- return NAN;
- }
- else {
- return x * (signbit(y) ? -1.0 : 1.0) * INFINITY;
- }
-}
+#ifndef MRB_NO_FLOAT
+mrb_float mrb_num_div_flo(mrb_state*, mrb_float, mrb_float);
+#define div_flo(x,y) mrb_num_div_flo(NULL, x, y)
+#endif
/* Arithmetic on (significand, exponent) pairs avoids premature overflow in
complex division */
@@ -341,8 +332,6 @@ complex_div(mrb_state *mrb, mrb_value self)
return complex_new(mrb, F(ldexp)(zr.s, zr.x), F(ldexp)(zi.s, zi.x));
}
-mrb_float mrb_num_div_flo(mrb_state*, mrb_float, mrb_float);
-
#ifndef MRB_USE_RATIONAL
mrb_int mrb_num_div_int(mrb_state *mrb, mrb_int x, mrb_int y);
@@ -365,7 +354,7 @@ int_div(mrb_state *mrb, mrb_value x)
x = complex_new(mrb, (mrb_float)a, 0);
return mrb_funcall_id(mrb, x, MRB_OPSYM(div), 1, y);
default:
- return mrb_float_value(mrb, div_flo(mrb, (mrb_float)a, mrb_to_flo(mrb, y)));
+ return mrb_float_value(mrb, div_flo((mrb_float)a, mrb_to_flo(mrb, y)));
}
}
@@ -385,7 +374,7 @@ int_quo(mrb_state *mrb, mrb_value x)
x = complex_new(mrb, (mrb_float)a, 0);
return mrb_funcall_id(mrb, x, MRB_OPSYM(div), 1, y);
default:
- return mrb_float_value(mrb, mrb_num_div_flo(mrb, (mrb_float)a, mrb_to_flo(mrb, y)));
+ return mrb_float_value(mrb, div_flo((mrb_float)a, mrb_to_flo(mrb, y)));
}
}
#endif

complex.c: use `mrb_num_div_flo` to avoid copying function.

This change relies that `mrb_num_div_flo` does not use `mrb` inside.