From 5a27b69aa63ee3806a4e10fd0b34da6014e1005c Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 6 Apr 2022 13:31:29 +0900 Subject: [PATCH] numeric.c: remove duplicated code in `int_divmod`. --- src/numeric.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/numeric.c b/src/numeric.c index 7962fe0ae..781a06b4b 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -1136,6 +1136,10 @@ int_mod(mrb_state *mrb, mrb_value x) #endif } +#ifndef MRB_NO_FLOAT +static mrb_value flo_divmod(mrb_state *mrb, mrb_value x); +#endif + /* * call-seq: * int.divmod(numeric) -> array @@ -1156,15 +1160,7 @@ int_divmod(mrb_state *mrb, mrb_value x) #ifdef MRB_NO_FLOAT mrb_raise(mrb, E_TYPE_ERROR, "non integer divmod"); #else - else { - mrb_float div, mod; - mrb_value a, b; - - flodivmod(mrb, (mrb_float)mrb_integer(x), mrb_as_float(mrb, y), &div, &mod); - a = mrb_int_value(mrb, (mrb_int)div); - b = mrb_float_value(mrb, mod); - return mrb_assoc_new(mrb, a, b); - } + return flo_divmod(mrb, x); #endif }