summaryrefslogtreecommitdiff
path: root/compar.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-06-11 05:20:24 (GMT)
committer卜部昌平 <shyouhei@ruby-lang.org>2020-06-29 02:05:41 (GMT)
commita93da4970be44a473b7b42e7516eb2663dece2c3 (patch)
treefd4de5a71768bd03a36608415158b159195d469a /compar.c
parent3a3728e4b37b422dae617ed75520e28426835053 (diff)
cmp_clamp: 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 'compar.c')
-rw-r--r--compar.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/compar.c b/compar.c
index 15ebfcd..6e64e3d 100644
--- a/compar.c
+++ b/compar.c
@@ -233,11 +233,9 @@ cmp_clamp(int argc, VALUE *argv, VALUE x)
}
if (!NIL_P(max)) {
if (excl) rb_raise(rb_eArgError, "cannot clamp with an exclusive range");
- if (!NIL_P(min) && cmpint(min, max) > 0) goto arg_error;
}
}
- else if (cmpint(min, max) > 0) {
- arg_error:
+ if (!NIL_P(min) && !NIL_P(max) && cmpint(min, max) > 0) {
rb_raise(rb_eArgError, "min argument must be smaller than max argument");
}