ruby-changes:61981
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:06:23 +0900 (JST)
Subject: [ruby-changes:61981] 9ec4f1f205 (master): rb_big_aref: do not goto into a branch
https://git.ruby-lang.org/ruby.git/commit/?id=9ec4f1f205 From 9ec4f1f205f7106e7b2e82abd69dbbc58978c586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Thu, 11 Jun 2020 13:18:22 +0900 Subject: rb_big_aref: 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. diff --git a/bignum.c b/bignum.c index 43eb939..310e731 100644 --- a/bignum.c +++ b/bignum.c @@ -6712,7 +6712,6 @@ rb_big_aref(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/bignum.c#L6712 return INT2FIX(0); bigtrunc(y); if (BIGSIZE(y) > sizeof(size_t)) { - out_of_range: return BIGNUM_SIGN(x) ? INT2FIX(0) : INT2FIX(1); } #if SIZEOF_SIZE_T <= SIZEOF_LONG @@ -6730,7 +6729,8 @@ rb_big_aref(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/bignum.c#L6729 s2 = shift%BITSPERDIG; bit = (BDIGIT)1 << s2; - if (s1 >= BIGNUM_LEN(x)) goto out_of_range; + if (s1 >= BIGNUM_LEN(x)) + return BIGNUM_SIGN(x) ? INT2FIX(0) : INT2FIX(1); xds = BDIGITS(x); if (BIGNUM_POSITIVE_P(x)) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/