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

ruby-changes:62046

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:62046] fdae2063fb (master): get_pat_quoted: do not goto into a branch

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

From fdae2063fb4730c0194e2a312ff250902a23df08 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: Thu, 18 Jun 2020 15:24:56 +0900
Subject: get_pat_quoted: 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/string.c b/string.c
index dc1df06..1a9fd3b 100644
--- a/string.c
+++ b/string.c
@@ -5032,8 +5032,7 @@ get_pat_quoted(VALUE pat, int check) https://github.com/ruby/ruby/blob/trunk/string.c#L5032
 {
     VALUE val;
 
-    if (SPECIAL_CONST_P(pat)) goto to_string;
-    switch (BUILTIN_TYPE(pat)) {
+    switch (OBJ_BUILTIN_TYPE(pat)) {
       case T_REGEXP:
 	return pat;
 
@@ -5041,7 +5040,6 @@ get_pat_quoted(VALUE pat, int check) https://github.com/ruby/ruby/blob/trunk/string.c#L5040
 	break;
 
       default:
-      to_string:
 	val = rb_check_string_type(pat);
 	if (NIL_P(val)) {
 	    Check_Type(pat, T_REGEXP);
-- 
cgit v0.10.2


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

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