diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-06-11 14:20:24 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-06-29 11:05:41 +0900 |
commit | a93da4970be44a473b7b42e7516eb2663dece2c3 (patch) | |
tree | fd4de5a71768bd03a36608415158b159195d469a | |
parent | 3a3728e4b37b422dae617ed75520e28426835053 (diff) | |
download | ruby-a93da4970be44a473b7b42e7516eb2663dece2c3.tar.gz |
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.
-rw-r--r-- | compar.c | 4 |
1 files changed, 1 insertions, 3 deletions
@@ -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"); } |