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

ruby-changes:61987

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

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

From a5342f46e6efc88bd0c0af9d30ba8af7194eb005 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: Thu, 11 Jun 2020 14:28:21 +0900
Subject: iseq_set_exception_table: 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/compile.c b/compile.c
index e481406..fd94d61 100644
--- a/compile.c
+++ b/compile.c
@@ -2428,7 +2428,8 @@ iseq_set_exception_table(rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/compile.c#L2428
     unsigned int tlen, i;
     struct iseq_catch_table_entry *entry;
 
-    if (NIL_P(ISEQ_COMPILE_DATA(iseq)->catch_table_ary)) goto no_catch_table;
+    iseq->body->catch_table = NULL;
+    if (NIL_P(ISEQ_COMPILE_DATA(iseq)->catch_table_ary)) return COMPILE_OK;
     tlen = (int)RARRAY_LEN(ISEQ_COMPILE_DATA(iseq)->catch_table_ary);
     tptr = RARRAY_CONST_PTR_TRANSIENT(ISEQ_COMPILE_DATA(iseq)->catch_table_ary);
 
@@ -2465,10 +2466,6 @@ iseq_set_exception_table(rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/compile.c#L2466
 	iseq->body->catch_table = table;
 	RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->catch_table_ary, 0); /* free */
     }
-    else {
-        no_catch_table:
-          iseq->body->catch_table = NULL;
-    }
 
     return COMPILE_OK;
 }
-- 
cgit v0.10.2


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

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