diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-06-19 15:51:17 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-06-29 11:05:41 +0900 |
commit | 421db59c9e2b9bdc1a91de50db1d0ffdb4663bd8 (patch) | |
tree | cbb2303181d997b0c7c12ec4101c4624f9037cbb /variable.c | |
parent | 3d636eccfc8412423ee592a65f4e5aaf4308c683 (diff) |
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.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3247
Diffstat (limited to 'variable.c')
-rw-r--r-- | variable.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/variable.c b/variable.c index 15c4288993..65549636ca 100644 --- a/variable.c +++ b/variable.c @@ -261,9 +261,7 @@ rb_path_to_class(VALUE pathname) pbeg = p; } if (!id) { - undefined_class: - rb_raise(rb_eArgError, "undefined class/module % "PRIsVALUE, - rb_str_subseq(pathname, 0, p-path)); + goto undefined_class; } c = rb_const_search(c, id, TRUE, FALSE, FALSE); if (c == Qundef) goto undefined_class; @@ -275,6 +273,10 @@ rb_path_to_class(VALUE pathname) RB_GC_GUARD(pathname); return c; + + undefined_class: + rb_raise(rb_eArgError, "undefined class/module % "PRIsVALUE, + rb_str_subseq(pathname, 0, p-path)); } VALUE |