summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2025-02-02 19:34:52 +0900
committerNobuyoshi Nakada <[email protected]>2025-02-02 19:34:52 +0900
commit8dd0d63550c4da2ba7939f371f73825caa2e932e (patch)
treef70ed625e6c6e80b66022c8daf836fb6770d8f5e /array.c
parentace39a3ed40cc32ff8d48893173413a7e05b8316 (diff)
[Bug #21106] Remove the useless last iteration
When only one element remains, this simply swaps the first identical element and has no actual effect.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12690
Diffstat (limited to 'array.c')
-rw-r--r--array.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/array.c b/array.c
index fc104388da..1d77615bab 100644
--- a/array.c
+++ b/array.c
@@ -6701,7 +6701,7 @@ rb_ary_shuffle_bang(rb_execution_context_t *ec, VALUE ary, VALUE randgen)
rb_ary_modify(ary);
i = len = RARRAY_LEN(ary);
RARRAY_PTR_USE(ary, ptr, {
- while (i) {
+ while (i > 1) {
long j = RAND_UPTO(i);
VALUE tmp;
if (len != RARRAY_LEN(ary) || ptr != RARRAY_CONST_PTR(ary)) {