aboutsummaryrefslogtreecommitdiffstats
path: root/bignum.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-06-11 12:56:05 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-06-29 11:05:41 +0900
commit184f0ab4c9e56e338de5b6fa7115c38406a184d4 (patch)
treebb6637d0fc3c570b85944f7f524b69f73d7934ed /bignum.c
parent5a7c0dd038773ada3b729df1417d4e4ad84944e3 (diff)
downloadruby-184f0ab4c9e56e338de5b6fa7115c38406a184d4.tar.gz
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.
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/bignum.c b/bignum.c
index 072662df8c..43eb939e14 100644
--- a/bignum.c
+++ b/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