diff options
author | 卜部昌平 <[email protected]> | 2020-06-16 11:22:04 +0900 |
---|---|---|
committer | 卜部昌平 <[email protected]> | 2020-06-29 11:05:41 +0900 |
commit | 82ed66a75a7abbf3b6e18be962ed9c11029b6722 (patch) | |
tree | 712983772f2143dc569344806f3247304561d27a /object.c | |
parent | 06ed9a7a045ab4a1e2e98910b06b988e6434fc44 (diff) |
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.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3247
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -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; + } } /*! |