Skip to content

Commit

Permalink
rb_enc_symname_type: refactor reduce goto
Browse files Browse the repository at this point in the history
A bit readable to me.
  • Loading branch information
shyouhei committed Mar 5, 2021
1 parent 0ead818 commit 0a43f0d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions symbol.c
Expand Up @@ -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) == '=') {
Expand All @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit 0a43f0d

Please sign in to comment.