ruby-changes:62020
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:07:41 +0900 (JST)
Subject: [ruby-changes:62020] b95b249784 (master): rb_mod_remove_cvar: do not goto into a branch
https://git.ruby-lang.org/ruby.git/commit/?id=b95b249784 From b95b249784d51697f9f890d6f2a4fba5be08e342 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: Mon, 22 Jun 2020 10:18:28 +0900 Subject: rb_mod_remove_cvar: 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/variable.c b/variable.c index 7477006..362ccdd 100644 --- a/variable.c +++ b/variable.c @@ -3335,9 +3335,7 @@ rb_mod_remove_cvar(VALUE mod, VALUE name) https://github.com/ruby/ruby/blob/trunk/variable.c#L3335 st_data_t val, n = id; if (!id) { - not_defined: - rb_name_err_raise("class variable %1$s not defined for %2$s", - mod, name); + goto not_defined; } rb_check_frozen(mod); if (RCLASS_IV_TBL(mod) && st_delete(RCLASS_IV_TBL(mod), &n, &val)) { @@ -3346,7 +3344,9 @@ rb_mod_remove_cvar(VALUE mod, VALUE name) https://github.com/ruby/ruby/blob/trunk/variable.c#L3344 if (rb_cvar_defined(mod, id)) { rb_name_err_raise("cannot remove %1$s for %2$s", mod, ID2SYM(id)); } - goto not_defined; + not_defined: + rb_name_err_raise("class variable %1$s not defined for %2$s", + mod, name); } VALUE -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/