зеркало из https://github.com/github/ruby.git
class_or_module_required: 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:
Родитель
03354feb6a
Коммит
1f6e74106f
4
object.c
4
object.c
|
@ -827,15 +827,13 @@ rb_obj_inspect(VALUE obj)
|
|||
static VALUE
|
||||
class_or_module_required(VALUE c)
|
||||
{
|
||||
if (SPECIAL_CONST_P(c)) goto not_class;
|
||||
switch (BUILTIN_TYPE(c)) {
|
||||
switch (OBJ_BUILTIN_TYPE(c)) {
|
||||
case T_MODULE:
|
||||
case T_CLASS:
|
||||
case T_ICLASS:
|
||||
break;
|
||||
|
||||
default:
|
||||
not_class:
|
||||
rb_raise(rb_eTypeError, "class or module required");
|
||||
}
|
||||
return c;
|
||||
|
|
Загрузка…
Ссылка в новой задаче