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

ruby-changes:62034

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

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

From 8b9b51bb3ba246590e528702285f5f5e92271b50 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: Tue, 16 Jun 2020 12:00:49 +0900
Subject: rb_method_name_error: 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/proc.c b/proc.c
index 371aa83..3ebd8d4 100644
--- a/proc.c
+++ b/proc.c
@@ -1865,7 +1865,7 @@ rb_method_name_error(VALUE klass, VALUE str) https://github.com/ruby/ruby/blob/trunk/proc.c#L1865
 {
 #define MSG(s) rb_fstring_lit("undefined method `%1$s' for"s" `%2$s'")
     VALUE c = klass;
-    VALUE s;
+    VALUE s = Qundef;
 
     if (FL_TEST(c, FL_SINGLETON)) {
 	VALUE obj = rb_ivar_get(klass, attached);
@@ -1878,13 +1878,11 @@ rb_method_name_error(VALUE klass, VALUE str) https://github.com/ruby/ruby/blob/trunk/proc.c#L1878
           default:
 	    break;
 	}
-	goto normal_class;
     }
     else if (RB_TYPE_P(c, T_MODULE)) {
 	s = MSG(" module");
     }
-    else {
-      normal_class:
+    if (s == Qundef) {
 	s = MSG(" class");
     }
     rb_name_err_raise_str(s, c, str);
-- 
cgit v0.10.2


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

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