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

ruby-changes:62005

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

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

From 6575766ea04ec49a77dad36d4a200fbd7b263d22 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 16:04:52 +0900
Subject: search_required: 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/load.c b/load.c
index 22c000e..8569287 100644
--- a/load.c
+++ b/load.c
@@ -924,9 +924,7 @@ search_required(VALUE fname, volatile VALUE *path, feature_func rb_feature_p) https://github.com/ruby/ruby/blob/trunk/load.c#L924
 
       default:
 	if (ft) {
-	  statically_linked:
-	    if (loading) *path = rb_filesystem_str_new_cstr(loading);
-	    return ft;
+            goto statically_linked;
 	}
         /* fall through */
       case 1:
@@ -936,6 +934,10 @@ search_required(VALUE fname, volatile VALUE *path, feature_func rb_feature_p) https://github.com/ruby/ruby/blob/trunk/load.c#L934
 	*path = tmp;
     }
     return type ? 's' : 'r';
+
+  statically_linked:
+    if (loading) *path = rb_filesystem_str_new_cstr(loading);
+    return ft;
 }
 
 static void
-- 
cgit v0.10.2


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

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