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.
This commit is contained in:
parent
5f926b2b00
commit
ad6512f359
Notes:
git
2020-06-29 11:06:44 +09:00
12
symbol.c
12
symbol.c
@ -316,7 +316,11 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
type = rb_sym_constant_char_p(m, e-m, enc) ? ID_CONST : ID_LOCAL;
|
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 (m >= e || (*m != '_' && !ISALPHA(*m) && ISASCII(*m))) {
|
||||||
if (len > 1 && *(e-1) == '=') {
|
if (len > 1 && *(e-1) == '=') {
|
||||||
type = rb_enc_symname_type(name, len-1, enc, allowed_attrset);
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
while (m < e && is_identchar(m, e, enc)) m += rb_enc_mbclen(m, e, enc);
|
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) {
|
switch (*m) {
|
||||||
case '!': case '?':
|
case '!': case '?':
|
||||||
if (type == ID_GLOBAL || type == ID_CLASS || type == ID_INSTANCE) return -1;
|
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;
|
++m;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
stophere:
|
||||||
return m == e ? type : -1;
|
return m == e ? type : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user