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:
parent
06ed9a7a04
commit
82ed66a75a
Notes:
git
2020-06-29 11:06:56 +09:00
16
object.c
16
object.c
@ -3530,13 +3530,7 @@ rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error)
|
|||||||
}
|
}
|
||||||
if (p == end) {
|
if (p == end) {
|
||||||
if (badcheck) {
|
if (badcheck) {
|
||||||
bad:
|
goto bad;
|
||||||
if (raise)
|
|
||||||
rb_invalid_str(q, "Float()");
|
|
||||||
else {
|
|
||||||
if (error) *error = 1;
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return d;
|
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);
|
rb_raise(rb_eArgError, "Float %.*s%s out of range", w, q, ellipsis);
|
||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
|
|
||||||
|
bad:
|
||||||
|
if (raise)
|
||||||
|
rb_invalid_str(q, "Float()");
|
||||||
|
else {
|
||||||
|
if (error) *error = 1;
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user