rb_mod_const_defined: 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
3b8d9badab
commit
60212cd8ee
Notes:
git
2020-06-29 11:06:57 +09:00
6
object.c
6
object.c
@ -2676,8 +2676,7 @@ rb_mod_const_defined(int argc, VALUE *argv, VALUE mod)
|
|||||||
pend = path + RSTRING_LEN(name);
|
pend = path + RSTRING_LEN(name);
|
||||||
|
|
||||||
if (p >= pend || !*p) {
|
if (p >= pend || !*p) {
|
||||||
wrong_name:
|
goto wrong_name;
|
||||||
rb_name_err_raise(wrong_constant_name, mod, name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p + 2 < pend && p[0] == ':' && p[1] == ':') {
|
if (p + 2 < pend && p[0] == ':' && p[1] == ':') {
|
||||||
@ -2750,6 +2749,9 @@ rb_mod_const_defined(int argc, VALUE *argv, VALUE mod)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Qtrue;
|
return Qtrue;
|
||||||
|
|
||||||
|
wrong_name:
|
||||||
|
rb_name_err_raise(wrong_constant_name, mod, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user