summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-06-16 11:22:04 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-06-29 11:05:41 +0900
commit82ed66a75a7abbf3b6e18be962ed9c11029b6722 (patch)
tree712983772f2143dc569344806f3247304561d27a /object.c
parent06ed9a7a045ab4a1e2e98910b06b988e6434fc44 (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.c16
1 files changed, 9 insertions, 7 deletions
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;
+ }
}
/*!