rb_cstr_to_dbl_raise: 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-16 11:22:04 +09:00
parent 06ed9a7a04
commit 82ed66a75a
Notes: git 2020-06-29 11:06:56 +09:00

View File

@ -3530,13 +3530,7 @@ rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error)
}
if (p == end) {
if (badcheck) {
bad:
if (raise)
rb_invalid_str(q, "Float()");
else {
if (error) *error = 1;
return 0.0;
}
goto bad;
}
return d;
}
@ -3611,6 +3605,14 @@ rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error)
rb_raise(rb_eArgError, "Float %.*s%s out of range", w, q, ellipsis);
}
return d;
bad:
if (raise)
rb_invalid_str(q, "Float()");
else {
if (error) *error = 1;
return 0.0;
}
}
/*!