1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

rand_range: 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.
This commit is contained in:
卜部昌平 2020-06-16 13:02:03 +09:00
parent 08202d1f0e
commit cc27cd26d7
Notes: git 2020-06-29 11:06:53 +09:00

View file

@ -1169,8 +1169,8 @@ rand_range(VALUE obj, rb_random_t* rnd, VALUE range)
long max;
vmax = v;
v = Qnil;
fixnum:
if (FIXNUM_P(vmax)) {
fixnum:
if ((max = FIX2LONG(vmax) - excl) >= 0) {
unsigned long r = random_ulong_limited(obj, rnd, (unsigned long)max);
v = ULONG2NUM(r);