From 82ed66a75a7abbf3b6e18be962ed9c11029b6722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Tue, 16 Jun 2020 11:22:04 +0900 Subject: 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. --- object.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'object.c') diff --git a/object.c b/object.c index 04a41cd5cf..fd7d02ba0d 100644 --- a/object.c +++ b/object.c @@ -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; + } } /*! -- cgit v1.2.3