[前][次][番号順一覧][スレッド一覧]

ruby-changes:62028

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:07:56 +0900 (JST)
Subject: [ruby-changes:62028] 7cf4625690 (master): feature_option: do not goto into a branch

https://git.ruby-lang.org/ruby.git/commit/?id=7cf4625690

From 7cf4625690454db5001ec5b13a88ef0d53a85bc9 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 15:32:39 +0900
Subject: feature_option: 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/ruby.c b/ruby.c
index a96bf1e..c3ee2ff 100644
--- a/ruby.c
+++ b/ruby.c
@@ -911,9 +911,7 @@ feature_option(const char *str, int len, void *arg, const unsigned int enable) https://github.com/ruby/ruby/blob/trunk/ruby.c#L911
     if (NAME_MATCH_P(#bit, str, len)) {set |= mask = FEATURE_BIT(bit); FEATURE_FOUND;}
     EACH_FEATURES(SET_FEATURE, ;);
     if (NAME_MATCH_P("all", str, len)) {
-      found:
-        FEATURE_SET_TO(*argp, mask, (mask & enable));
-	return;
+        goto found;
     }
 #if AMBIGUOUS_FEATURE_NAMES
     if (matched == 1) goto found;
@@ -933,6 +931,11 @@ feature_option(const char *str, int len, void *arg, const unsigned int enable) https://github.com/ruby/ruby/blob/trunk/ruby.c#L931
     rb_warn("unknown argument for --%s: `%.*s'",
 	    enable ? "enable" : "disable", len, str);
     rb_warn("features are [%.*s].", (int)strlen(list), list);
+    return;
+
+  found:
+    FEATURE_SET_TO(*argp, mask, (mask & enable));
+    return;
 }
 
 static void
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]