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.
This commit is contained in:
parent
421db59c9e
commit
fc45a061b9
Notes:
git
2020-06-29 11:06:38 +09:00
27
variable.c
27
variable.c
@ -949,29 +949,22 @@ iv_index_tbl_newsize(struct ivar_update *ivup)
|
|||||||
static int
|
static int
|
||||||
generic_ivar_update(st_data_t *k, st_data_t *v, st_data_t u, int existing)
|
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;
|
struct ivar_update *ivup = (struct ivar_update *)u;
|
||||||
uint32_t newsize;
|
struct gen_ivtbl *ivtbl = 0;
|
||||||
int ret = ST_CONTINUE;
|
|
||||||
struct gen_ivtbl *ivtbl;
|
|
||||||
|
|
||||||
if (existing) {
|
if (existing) {
|
||||||
ivtbl = (struct gen_ivtbl *)*v;
|
ivtbl = (struct gen_ivtbl *)*v;
|
||||||
if (ivup->index >= ivtbl->numiv) {
|
if (ivup->index < ivtbl->numiv) {
|
||||||
goto resize;
|
ivup->u.ivtbl = ivtbl;
|
||||||
}
|
return ST_STOP;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
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;
|
ivup->u.ivtbl = ivtbl;
|
||||||
return ret;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user