rb_path_to_class: 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
3d636eccfc
commit
421db59c9e
Notes:
git
2020-06-29 11:06:38 +09:00
@ -261,9 +261,7 @@ rb_path_to_class(VALUE pathname)
|
|||||||
pbeg = p;
|
pbeg = p;
|
||||||
}
|
}
|
||||||
if (!id) {
|
if (!id) {
|
||||||
undefined_class:
|
goto undefined_class;
|
||||||
rb_raise(rb_eArgError, "undefined class/module % "PRIsVALUE,
|
|
||||||
rb_str_subseq(pathname, 0, p-path));
|
|
||||||
}
|
}
|
||||||
c = rb_const_search(c, id, TRUE, FALSE, FALSE);
|
c = rb_const_search(c, id, TRUE, FALSE, FALSE);
|
||||||
if (c == Qundef) goto undefined_class;
|
if (c == Qundef) goto undefined_class;
|
||||||
@ -275,6 +273,10 @@ rb_path_to_class(VALUE pathname)
|
|||||||
RB_GC_GUARD(pathname);
|
RB_GC_GUARD(pathname);
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
|
|
||||||
|
undefined_class:
|
||||||
|
rb_raise(rb_eArgError, "undefined class/module % "PRIsVALUE,
|
||||||
|
rb_str_subseq(pathname, 0, p-path));
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user