ruby-changes:62058
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:08:35 +0900 (JST)
Subject: [ruby-changes:62058] d49924ed81 (master): rb_str_match: do not goto into a branch
https://git.ruby-lang.org/ruby.git/commit/?id=d49924ed81 From d49924ed81af7f5f00841ce7b4aa423a924d3af0 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: Wed, 17 Jun 2020 16:05:43 +0900 Subject: rb_str_match: 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 2abb829..8ccfac5 100644 --- a/string.c +++ b/string.c @@ -3864,15 +3864,13 @@ rb_str_rindex_m(int argc, VALUE *argv, VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L3864 static VALUE rb_str_match(VALUE x, VALUE y) { - if (SPECIAL_CONST_P(y)) goto generic; - switch (BUILTIN_TYPE(y)) { + switch (OBJ_BUILTIN_TYPE(y)) { case T_STRING: rb_raise(rb_eTypeError, "type mismatch: String given"); case T_REGEXP: return rb_reg_match(y, x); - generic: default: return rb_funcall(y, idEqTilde, 1, x); } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/