utc_offset_arg: 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:
卜部昌平 2020-06-19 12:44:57 +09:00
parent 1c0a97bfad
commit ce6be8889f
Notes: git 2025-04-09 13:49:37 +00:00

5
time.c
View File

@ -2079,8 +2079,7 @@ utc_offset_arg(VALUE arg)
int n = 0; int n = 0;
char *s = RSTRING_PTR(tmp); char *s = RSTRING_PTR(tmp);
if (!rb_enc_str_asciicompat_p(tmp)) { if (!rb_enc_str_asciicompat_p(tmp)) {
invalid_utc_offset: goto invalid_utc_offset;
return Qnil;
} }
switch (RSTRING_LEN(tmp)) { switch (RSTRING_LEN(tmp)) {
case 1: case 1:
@ -2131,6 +2130,8 @@ utc_offset_arg(VALUE arg)
else { else {
return num_exact(arg); return num_exact(arg);
} }
invalid_utc_offset:
return Qnil;
} }
static void static void