vm_getivar: 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:
卜部昌平 2020-06-22 11:07:26 +09:00
parent 6e67b30503
commit 1bf0d36171
Notes: git 2020-06-29 11:06:35 +09:00

View File

@ -1080,6 +1080,25 @@ vm_getivar(VALUE obj, ID id, IVC ic, const struct rb_callcache *cc, int is_attr)
iv_index_tbl = ROBJECT_IV_INDEX_TBL(obj);
numiv = ROBJECT_NUMIV(obj);
ivptr = ROBJECT_IVPTR(obj);
goto fill;
}
else if (FL_TEST_RAW(obj, FL_EXIVAR)) {
struct gen_ivtbl *ivtbl;
if (LIKELY(st_lookup(rb_ivar_generic_ivtbl(), (st_data_t)obj, (st_data_t *)&ivtbl))) {
numiv = ivtbl->numiv;
ivptr = ivtbl->ivptr;
iv_index_tbl = RCLASS_IV_INDEX_TBL(rb_obj_class(obj));
goto fill;
}
else {
goto ret;
}
}
else {
// T_CLASS / T_MODULE
goto general_path;
}
fill:
if (iv_index_tbl) {
@ -1097,21 +1116,6 @@ vm_getivar(VALUE obj, ID id, IVC ic, const struct rb_callcache *cc, int is_attr)
}
}
}
}
else if (FL_TEST_RAW(obj, FL_EXIVAR)) {
struct gen_ivtbl *ivtbl;
if (LIKELY(st_lookup(rb_ivar_generic_ivtbl(), (st_data_t)obj, (st_data_t *)&ivtbl))) {
numiv = ivtbl->numiv;
ivptr = ivtbl->ivptr;
iv_index_tbl = RCLASS_IV_INDEX_TBL(rb_obj_class(obj));
goto fill;
}
}
else {
// T_CLASS / T_MODULE
goto general_path;
}
ret:
if (LIKELY(val != Qundef)) {