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

ruby-changes:62030

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

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

From 1f6e74106f452057d857e7f935b13b2064cfac98 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 10:49:02 +0900
Subject: class_or_module_required: 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/object.c b/object.c
index 03cc51a..0c59985 100644
--- a/object.c
+++ b/object.c
@@ -827,15 +827,13 @@ rb_obj_inspect(VALUE obj) https://github.com/ruby/ruby/blob/trunk/object.c#L827
 static VALUE
 class_or_module_required(VALUE c)
 {
-    if (SPECIAL_CONST_P(c)) goto not_class;
-    switch (BUILTIN_TYPE(c)) {
+    switch (OBJ_BUILTIN_TYPE(c)) {
       case T_MODULE:
       case T_CLASS:
       case T_ICLASS:
 	break;
 
       default:
-      not_class:
 	rb_raise(rb_eTypeError, "class or module required");
     }
     return c;
-- 
cgit v0.10.2


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

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