ruby-changes:62069
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:08:45 +0900 (JST)
Subject: [ruby-changes:62069] 673ddea934 (master): get_pat: do not goto into a branch
https://git.ruby-lang.org/ruby.git/commit/?id=673ddea934 From 673ddea934db68a074e25925602a32b2994e3b06 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:16 +0900 Subject: get_pat: 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 f7a26f5..dc1df06 100644 --- a/string.c +++ b/string.c @@ -5009,8 +5009,7 @@ get_pat(VALUE pat) https://github.com/ruby/ruby/blob/trunk/string.c#L5009 { VALUE val; - if (SPECIAL_CONST_P(pat)) goto to_string; - switch (BUILTIN_TYPE(pat)) { + switch (OBJ_BUILTIN_TYPE(pat)) { case T_REGEXP: return pat; @@ -5018,7 +5017,6 @@ get_pat(VALUE pat) https://github.com/ruby/ruby/blob/trunk/string.c#L5017 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/