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

ruby-changes:62050

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

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

From 8fc8912109cf7426afe6334850204744988c7a3d 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: Fri, 19 Jun 2020 10:50:43 +0900
Subject: exec_recursive: 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/thread.c b/thread.c
index 6fdddde..3337735 100644
--- a/thread.c
+++ b/thread.c
@@ -5162,10 +5162,7 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE https://github.com/ruby/ruby/blob/trunk/thread.c#L5162
 	    }
 	    EC_POP_TAG();
 	    if (!recursive_pop(p.list, p.obj, p.pairid)) {
-	      invalid:
-		rb_raise(rb_eTypeError, "invalid inspect_tbl pair_list "
-			 "for %+"PRIsVALUE" in %+"PRIsVALUE,
-			 sym, rb_thread_current());
+                goto invalid;
 	    }
 	    if (state != TAG_NONE) EC_JUMP_TAG(GET_EC(), state);
 	    result = ret;
@@ -5173,6 +5170,11 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE https://github.com/ruby/ruby/blob/trunk/thread.c#L5170
     }
     *(volatile struct exec_recursive_params *)&p;
     return result;
+
+  invalid:
+    rb_raise(rb_eTypeError, "invalid inspect_tbl pair_list "
+             "for %+"PRIsVALUE" in %+"PRIsVALUE,
+             sym, rb_thread_current());
 }
 
 /*
-- 
cgit v0.10.2


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

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