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

ruby-changes:62045

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

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

From 6e67b30503f2931d9538d439545c3b1cff51fc80 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, 22 Jun 2020 11:00:31 +0900
Subject: method_missing: 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/vm_eval.c b/vm_eval.c
index b90ff37..98352ba 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -820,8 +820,7 @@ method_missing(VALUE obj, ID id, int argc, const VALUE *argv, enum method_missin https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L820
     ec->method_missing_reason = call_status;
 
     if (id == idMethodMissing) {
-      missing:
-	raise_method_missing(ec, argc, argv, obj, call_status | MISSING_MISSING);
+        goto missing;
     }
 
     nargv = ALLOCV_N(VALUE, work, argc + 1);
@@ -845,6 +844,8 @@ method_missing(VALUE obj, ID id, int argc, const VALUE *argv, enum method_missin https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L844
     result = rb_vm_call_kw(ec, obj, idMethodMissing, argc, argv, me, kw_splat);
     if (work) ALLOCV_END(work);
     return result;
+  missing:
+    raise_method_missing(ec, argc, argv, obj, call_status | MISSING_MISSING);
 }
 
 #ifndef MJIT_HEADER
-- 
cgit v0.10.2


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

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