From 8dd0d63550c4da2ba7939f371f73825caa2e932e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 2 Feb 2025 19:34:52 +0900 Subject: [Bug #21106] Remove the useless last iteration When only one element remains, this simply swaps the first identical element and has no actual effect. --- array.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'array.c') 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)) { -- cgit v1.2.3