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

ruby-changes:62018

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

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

From c5f43451389a9a19d14c34e553d271038a87be99 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, 15 Jun 2020 14:36:41 +0900
Subject: get_envparam_double: 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/gc.c b/gc.c
index 05b8fb3..a2a7997 100644
--- a/gc.c
+++ b/gc.c
@@ -9389,13 +9389,15 @@ get_envparam_double(const char *name, double *default_value, double lower_bound, https://github.com/ruby/ruby/blob/trunk/gc.c#L9389
 	    }
 	}
 	else {
-	  accept:
-	    if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%f (default value: %f)\n", name, val, *default_value);
-	    *default_value = val;
-	    return 1;
+            goto accept;
 	}
     }
     return 0;
+
+  accept:
+    if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%f (default value: %f)\n", name, val, *default_value);
+    *default_value = val;
+    return 1;
 }
 
 static void
-- 
cgit v0.10.2


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

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