ruby-changes:65393
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Fri, 5 Mar 2021 16:37:15 +0900 (JST)
Subject: [ruby-changes:65393] 0a43f0de27 (master): rb_enc_symname_type: refactor reduce goto
https://git.ruby-lang.org/ruby.git/commit/?id=0a43f0de27 From 0a43f0de27b8724a0932be2679aa39467c68f750 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, 5 Mar 2021 16:26:34 +0900 Subject: rb_enc_symname_type: refactor reduce goto A bit readable to me. --- symbol.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/symbol.c b/symbol.c index 1a46985..7dda4d2 100644 --- a/symbol.c +++ b/symbol.c @@ -372,9 +372,8 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a https://github.com/ruby/ruby/blob/trunk/symbol.c#L372 switch (f.kind) { case invalid: return -1; - case stophere: goto stophere; - case needmore: break; - } + case stophere: break; + case needmore: if (m >= e || (*m != '_' && !ISALPHA(*m) && ISASCII(*m))) { if (len > 1 && *(e-1) == '=') { @@ -384,7 +383,7 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a https://github.com/ruby/ruby/blob/trunk/symbol.c#L383 return -1; } while (m < e && is_identchar(m, e, enc)) m += rb_enc_mbclen(m, e, enc); - if (m >= e) goto stophere; + if (m >= e) break; switch (*m) { case '!': case '?': if (type == ID_GLOBAL || type == ID_CLASS || type == ID_INSTANCE) return -1; @@ -398,8 +397,8 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a https://github.com/ruby/ruby/blob/trunk/symbol.c#L397 ++m; break; } + } - stophere: return m == e ? type : -1; } -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/