From 3b8d9badab0433e3022c2d423c3f53b00de634d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Tue, 16 Jun 2020 10:50:53 +0900 Subject: [PATCH] rb_mod_const_get: 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. --- object.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/object.c b/object.c index 0c59985877..6ecf760c40 100644 --- a/object.c +++ b/object.c @@ -2504,8 +2504,7 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod) pend = path + RSTRING_LEN(name); if (p >= pend || !*p) { - wrong_name: - rb_name_err_raise(wrong_constant_name, mod, name); + goto wrong_name; } if (p + 2 < pend && p[0] == ':' && p[1] == ':') { @@ -2572,6 +2571,9 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod) } return mod; + + wrong_name: + rb_name_err_raise(wrong_constant_name, mod, name); } /*