ruby-changes:62038
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:08:18 +0900 (JST)
Subject: [ruby-changes:62038] 60212cd8ee (master): rb_mod_const_defined: do not goto into a branch
https://git.ruby-lang.org/ruby.git/commit/?id=60212cd8ee From 60212cd8eef55b1b3c4482dfd0c65d2151cb2d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Tue, 16 Jun 2020 10:52:30 +0900 Subject: rb_mod_const_defined: 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. diff --git a/object.c b/object.c index 6ecf760..cec3890 100644 --- a/object.c +++ b/object.c @@ -2676,8 +2676,7 @@ rb_mod_const_defined(int argc, VALUE *argv, VALUE mod) https://github.com/ruby/ruby/blob/trunk/object.c#L2676 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] == ':') { @@ -2750,6 +2749,9 @@ rb_mod_const_defined(int argc, VALUE *argv, VALUE mod) https://github.com/ruby/ruby/blob/trunk/object.c#L2749 } return Qtrue; + + wrong_name: + rb_name_err_raise(wrong_constant_name, mod, name); } /* -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/