From 250189f54f2cf690195573ee82082c42b21ccac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Tue, 16 Jun 2020 10:05:46 +0900 Subject: int_pow: do not goto into a branch I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. --- numeric.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'numeric.c') diff --git a/numeric.c b/numeric.c index 8843be9e58..52d7a74344 100644 --- a/numeric.c +++ b/numeric.c @@ -3978,13 +3978,7 @@ int_pow(long x, unsigned long y) do { while (y % 2 == 0) { if (!FIT_SQRT_LONG(x)) { - VALUE v; - bignum: - v = rb_big_pow(rb_int2big(x), LONG2NUM(y)); - if (RB_FLOAT_TYPE_P(v)) /* infinity due to overflow */ - return v; - if (z != 1) v = rb_big_mul(rb_int2big(neg ? -z : z), v); - return v; + goto bignum; } x = x * x; y >>= 1; @@ -3998,6 +3992,14 @@ int_pow(long x, unsigned long y) } while (--y); if (neg) z = -z; return LONG2NUM(z); + + VALUE v; + bignum: + v = rb_big_pow(rb_int2big(x), LONG2NUM(y)); + if (RB_FLOAT_TYPE_P(v)) /* infinity due to overflow */ + return v; + if (z != 1) v = rb_big_mul(rb_int2big(neg ? -z : z), v); + return v; } VALUE -- cgit v1.2.3