diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-06-11 12:56:05 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-06-29 11:05:41 +0900 |
commit | 184f0ab4c9e56e338de5b6fa7115c38406a184d4 (patch) | |
tree | bb6637d0fc3c570b85944f7f524b69f73d7934ed | |
parent | 5a7c0dd038773ada3b729df1417d4e4ad84944e3 (diff) |
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.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3247
-rw-r--r-- | bignum.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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 |