summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-06-19 10:46:55 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-06-29 11:05:41 +0900
commitad6512f359fe38d587715c618380e245af586be1 (patch)
tree96c0f74d63e31bb69841169dbb2a5b55c92d1eb6
parent5f926b2b0013fc196ba627e70b7961a71aabca11 (diff)
rb_enc_synmane_type: 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.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3247
-rw-r--r--symbol.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/symbol.c b/symbol.c
index 185c6a8c82..b40af8883f 100644
--- a/symbol.c
+++ b/symbol.c
@@ -316,7 +316,11 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a
default:
type = rb_sym_constant_char_p(m, e-m, enc) ? ID_CONST : ID_LOCAL;
- id:
+ goto id;
+ }
+ goto stophere;
+
+ id:
if (m >= e || (*m != '_' && !ISALPHA(*m) && ISASCII(*m))) {
if (len > 1 && *(e-1) == '=') {
type = rb_enc_symname_type(name, len-1, enc, allowed_attrset);
@@ -325,7 +329,7 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a
return -1;
}
while (m < e && is_identchar(m, e, enc)) m += rb_enc_mbclen(m, e, enc);
- if (m >= e) break;
+ if (m >= e) goto stophere;
switch (*m) {
case '!': case '?':
if (type == ID_GLOBAL || type == ID_CLASS || type == ID_INSTANCE) return -1;
@@ -339,8 +343,8 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a
++m;
break;
}
- break;
- }
+
+ stophere:
return m == e ? type : -1;
}