rb_int_parse_cstr: 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
5a7c0dd038
commit
184f0ab4c9
Notes:
git
2020-06-29 11:07:15 +09:00
10
bignum.c
10
bignum.c
@ -4094,10 +4094,7 @@ rb_int_parse_cstr(const char *str, ssize_t len, char **endp, size_t *ndigits,
|
||||
} while (0)
|
||||
|
||||
if (!str) {
|
||||
bad:
|
||||
if (endp) *endp = (char *)str;
|
||||
if (ndigits) *ndigits = num_digits;
|
||||
return z;
|
||||
goto bad;
|
||||
}
|
||||
if (len && (flags & RB_INT_PARSE_SIGN)) {
|
||||
while (ISSPACE(*str)) ADV(1);
|
||||
@ -4261,6 +4258,11 @@ rb_int_parse_cstr(const char *str, ssize_t len, char **endp, size_t *ndigits,
|
||||
}
|
||||
|
||||
return bignorm(z);
|
||||
|
||||
bad:
|
||||
if (endp) *endp = (char *)str;
|
||||
if (ndigits) *ndigits = num_digits;
|
||||
return z;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
Loading…
x
Reference in New Issue
Block a user