diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-06-11 12:53:12 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-06-29 11:05:41 +0900 |
commit | 5a7c0dd038773ada3b729df1417d4e4ad84944e3 (patch) | |
tree | b1c8e1477fee869c5e4640bee4ae005f26a3e2f2 /bignum.c | |
parent | 4dfc2f2e3d95b4b9a3b79c1fdf2eb721beacdc0c (diff) |
str2big_scan_digits: 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
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -3771,12 +3771,12 @@ str2big_scan_digits(const char *s, const char *str, int base, int badcheck, size return TRUE; } - if (badcheck && *str == '_') goto bad; + if (badcheck && *str == '_') return FALSE; while ((c = *str++) != 0) { if (c == '_') { if (nondigit) { - if (badcheck) goto bad; + if (badcheck) return FALSE; break; } nondigit = (char) c; @@ -3791,7 +3791,7 @@ str2big_scan_digits(const char *s, const char *str, int base, int badcheck, size } if (len > 0 && !--len) break; } - if (badcheck && nondigit) goto bad; + if (badcheck && nondigit) return FALSE; if (badcheck && len) { str--; while (*str && ISSPACE(*str)) { @@ -3799,7 +3799,6 @@ str2big_scan_digits(const char *s, const char *str, int base, int badcheck, size if (len > 0 && !--len) break; } if (len && *str) { - bad: return FALSE; } } |