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

ruby-changes:62010

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

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

From 0b1b73451528d946060f4876aa38fc3278899deb 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 11:58:30 +0900
Subject: rb_class_modify_check: 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 c44bf13..65414d2 100644
--- a/eval.c
+++ b/eval.c
@@ -456,7 +456,6 @@ void https://github.com/ruby/ruby/blob/trunk/eval.c#L456
 rb_class_modify_check(VALUE klass)
 {
     if (SPECIAL_CONST_P(klass)) {
-      noclass:
 	Check_Type(klass, T_CLASS);
     }
     if (OBJ_FROZEN(klass)) {
@@ -489,7 +488,7 @@ rb_class_modify_check(VALUE klass) https://github.com/ruby/ruby/blob/trunk/eval.c#L488
 		desc = "class";
 		break;
 	      default:
-		goto noclass;
+                Check_Type(klass, T_CLASS);
 	    }
 	}
         rb_frozen_error_raise(klass, "can't modify frozen %s: %"PRIsVALUE, desc, klass);
-- 
cgit v0.10.2


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

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