Skip to content

Commit 8dd0d63

Browse files
committed
[Bug #21106] Remove the useless last iteration
When only one element remains, this simply swaps the first identical element and has no actual effect.
1 parent ace39a3 commit 8dd0d63

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6701,7 +6701,7 @@ rb_ary_shuffle_bang(rb_execution_context_t *ec, VALUE ary, VALUE randgen)
67016701
rb_ary_modify(ary);
67026702
i = len = RARRAY_LEN(ary);
67036703
RARRAY_PTR_USE(ary, ptr, {
6704-
while (i) {
6704+
while (i > 1) {
67056705
long j = RAND_UPTO(i);
67066706
VALUE tmp;
67076707
if (len != RARRAY_LEN(ary) || ptr != RARRAY_CONST_PTR(ary)) {

0 commit comments

Comments
 (0)