From 421db59c9e2b9bdc1a91de50db1d0ffdb4663bd8 Mon Sep 17 00:00:00 2001 From: 卜部昌平 Date: Fri, 19 Jun 2020 15:51:17 +0900 Subject: 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. --- variable.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'variable.c') 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 -- cgit v1.2.3