ruby-changes:62063
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:08:40 +0900 (JST)
Subject: [ruby-changes:62063] fc45a061b9 (master): generic_ivar_update: do not goto into a branch
https://git.ruby-lang.org/ruby.git/commit/?id=fc45a061b9 From fc45a061b9c317bfe1f7a9b726e7056db93950c8 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: Mon, 22 Jun 2020 09:25:25 +0900 Subject: generic_ivar_update: 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/variable.c b/variable.c index 6554963..144f943 100644 --- a/variable.c +++ b/variable.c @@ -949,29 +949,22 @@ iv_index_tbl_newsize(struct ivar_update *ivup) https://github.com/ruby/ruby/blob/trunk/variable.c#L949 static int generic_ivar_update(st_data_t *k, st_data_t *v, st_data_t u, int existing) { - VALUE obj = (VALUE)*k; struct ivar_update *ivup = (struct ivar_update *)u; - uint32_t newsize; - int ret = ST_CONTINUE; - struct gen_ivtbl *ivtbl; + struct gen_ivtbl *ivtbl = 0; if (existing) { ivtbl = (struct gen_ivtbl *)*v; - if (ivup->index >= ivtbl->numiv) { - goto resize; - } - ret = ST_STOP; - } - else { - FL_SET(obj, FL_EXIVAR); - ivtbl = 0; -resize: - newsize = iv_index_tbl_newsize(ivup); - ivtbl = gen_ivtbl_resize(ivtbl, newsize); - *v = (st_data_t)ivtbl; + if (ivup->index < ivtbl->numiv) { + ivup->u.ivtbl = ivtbl; + return ST_STOP; + } } + FL_SET((VALUE)*k, FL_EXIVAR); + uint32_t newsize = iv_index_tbl_newsize(ivup); + ivtbl = gen_ivtbl_resize(ivtbl, newsize); + *v = (st_data_t)ivtbl; ivup->u.ivtbl = ivtbl; - return ret; + return ST_CONTINUE; } static VALUE -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/