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,23 +1080,7 @@ 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);
fill:
if (iv_index_tbl) {
if (st_lookup(iv_index_tbl, id, &index)) {
if (!is_attr) {
ic->index = index;
ic->ic_serial = RCLASS_SERIAL(RBASIC(obj)->klass);
}
else { /* call_info */
vm_cc_attr_index_set(cc, (int)index + 1);
}
if (index < numiv) {
val = ivptr[index];
}
}
}
goto fill;
}
else if (FL_TEST_RAW(obj, FL_EXIVAR)) {
struct gen_ivtbl *ivtbl;
@ -1107,12 +1091,32 @@ vm_getivar(VALUE obj, ID id, IVC ic, const struct rb_callcache *cc, int is_attr)
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) {
if (st_lookup(iv_index_tbl, id, &index)) {
if (!is_attr) {
ic->index = index;
ic->ic_serial = RCLASS_SERIAL(RBASIC(obj)->klass);
}
else { /* call_info */
vm_cc_attr_index_set(cc, (int)index + 1);
}
if (index < numiv) {
val = ivptr[index];
}
}
}
ret:
if (LIKELY(val != Qundef)) {
return val;