diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-06-22 09:25:25 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-06-29 11:05:41 +0900 |
commit | fc45a061b9c317bfe1f7a9b726e7056db93950c8 (patch) | |
tree | ea018718a1fbfb2e6f30dac098807517ab6bdc20 /variable.c | |
parent | 421db59c9e2b9bdc1a91de50db1d0ffdb4663bd8 (diff) |
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.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3247
Diffstat (limited to 'variable.c')
-rw-r--r-- | variable.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/variable.c b/variable.c index 65549636ca..144f943618 100644 --- a/variable.c +++ b/variable.c @@ -949,29 +949,22 @@ iv_index_tbl_newsize(struct ivar_update *ivup) 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 |