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

ruby-changes:62011

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

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

From 13bdbfcecbe7652c4c8315d1c615e205b83123e8 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 12:01:50 +0900
Subject: setup_exception: 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/eval.c b/eval.c
index 65414d2..ac442dd 100644
--- a/eval.c
+++ b/eval.c
@@ -641,16 +641,19 @@ setup_exception(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE https://github.com/ruby/ruby/blob/trunk/eval.c#L641
     }
 
     if (rb_ec_set_raised(ec)) {
-      fatal:
-	ec->errinfo = exception_error;
-	rb_ec_reset_raised(ec);
-	EC_JUMP_TAG(ec, TAG_FATAL);
+        goto fatal;
     }
 
     if (tag != TAG_FATAL) {
 	RUBY_DTRACE_HOOK(RAISE, rb_obj_classname(ec->errinfo));
 	EXEC_EVENT_HOOK(ec, RUBY_EVENT_RAISE, ec->cfp->self, 0, 0, 0, mesg);
     }
+    return;
+
+  fatal:
+    ec->errinfo = exception_error;
+    rb_ec_reset_raised(ec);
+    EC_JUMP_TAG(ec, TAG_FATAL);
 }
 
 /*! \private */
-- 
cgit v0.10.2


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

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