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

ruby-changes:62014

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

https://git.ruby-lang.org/ruby.git/commit/?id=9c92dcf366

From 9c92dcf366d2f66a085bd23f0b4934415e1a15b2 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: Fri, 12 Jun 2020 13:57:30 +0900
Subject: ibf_dump_object_object: 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/compile.c b/compile.c
index bb9cdc0..f641cf9 100644
--- a/compile.c
+++ b/compile.c
@@ -11610,12 +11610,9 @@ ibf_dump_object_object(struct ibf_dump *dump, VALUE obj) https://github.com/ruby/ruby/blob/trunk/compile.c#L11610
     IBF_W_ALIGN(ibf_offset_t);
     current_offset = ibf_dump_pos(dump);
 
-    if (SPECIAL_CONST_P(obj)) {
-        if (RB_TYPE_P(obj, T_SYMBOL) ||
-            RB_TYPE_P(obj, T_FLOAT)) {
-            obj_header.internal = FALSE;
-            goto dump_object;
-        }
+    if (SPECIAL_CONST_P(obj) &&
+        ! (RB_TYPE_P(obj, T_SYMBOL) ||
+           RB_TYPE_P(obj, T_FLOAT))) {
         obj_header.special_const = TRUE;
         obj_header.frozen = TRUE;
         obj_header.internal = TRUE;
@@ -11623,8 +11620,7 @@ ibf_dump_object_object(struct ibf_dump *dump, VALUE obj) https://github.com/ruby/ruby/blob/trunk/compile.c#L11620
         ibf_dump_write_small_value(dump, obj);
     }
     else {
-        obj_header.internal = (RBASIC_CLASS(obj) == 0) ? TRUE : FALSE;
-      dump_object:
+        obj_header.internal = SPECIAL_CONST_P(obj) ? FALSE : (RBASIC_CLASS(obj) == 0) ? TRUE : FALSE;
         obj_header.special_const = FALSE;
         obj_header.frozen = FL_TEST(obj, FL_FREEZE) ? TRUE : FALSE;
         ibf_dump_object_object_header(dump, obj_header);
-- 
cgit v0.10.2


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

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