summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2021-03-05 16:26:34 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2021-03-05 16:33:29 +0900
commit0a43f0de27b8724a0932be2679aa39467c68f750 (patch)
tree3cb5fba4f8dd770ff62680ac62fe770d524a9925
parent0ead818d81c975275238878c81f300dd404e0722 (diff)
rb_enc_symname_type: refactor reduce goto
A bit readable to me.
-rw-r--r--symbol.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/symbol.c b/symbol.c
index 1a46985531..7dda4d2c9c 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
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
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
++m;
break;
}
+ }
- stophere:
return m == e ? type : -1;
}