rb_mod_remove_cvar: 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
1e9d58391c
commit
b95b249784
Notes:
git
2020-06-29 11:06:37 +09:00
@ -3335,9 +3335,7 @@ rb_mod_remove_cvar(VALUE mod, VALUE name)
|
|||||||
st_data_t val, n = id;
|
st_data_t val, n = id;
|
||||||
|
|
||||||
if (!id) {
|
if (!id) {
|
||||||
not_defined:
|
goto not_defined;
|
||||||
rb_name_err_raise("class variable %1$s not defined for %2$s",
|
|
||||||
mod, name);
|
|
||||||
}
|
}
|
||||||
rb_check_frozen(mod);
|
rb_check_frozen(mod);
|
||||||
if (RCLASS_IV_TBL(mod) && st_delete(RCLASS_IV_TBL(mod), &n, &val)) {
|
if (RCLASS_IV_TBL(mod) && st_delete(RCLASS_IV_TBL(mod), &n, &val)) {
|
||||||
@ -3346,7 +3344,9 @@ rb_mod_remove_cvar(VALUE mod, VALUE name)
|
|||||||
if (rb_cvar_defined(mod, id)) {
|
if (rb_cvar_defined(mod, id)) {
|
||||||
rb_name_err_raise("cannot remove %1$s for %2$s", mod, ID2SYM(id));
|
rb_name_err_raise("cannot remove %1$s for %2$s", mod, ID2SYM(id));
|
||||||
}
|
}
|
||||||
goto not_defined;
|
not_defined:
|
||||||
|
rb_name_err_raise("class variable %1$s not defined for %2$s",
|
||||||
|
mod, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user