summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-06-16 13:02:03 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-06-29 11:05:41 +0900
commitcc27cd26d728d285aed728e730994d31f5ac1241 (patch)
treea4292c8a7eecc8a70f21ff06a6870c5da9f1280d /random.c
parent08202d1f0e120bc09431149e3fe2284f992dbb6d (diff)
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.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3247
Diffstat (limited to 'random.c')
-rw-r--r--random.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/random.c b/random.c
index 708f5c4..8a59d1c 100644
--- a/random.c
+++ b/random.c
@@ -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);