diff options
author | Nobuyoshi Nakada <[email protected]> | 2025-02-02 19:34:52 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2025-02-02 19:34:52 +0900 |
commit | 8dd0d63550c4da2ba7939f371f73825caa2e932e (patch) | |
tree | f70ed625e6c6e80b66022c8daf836fb6770d8f5e /array.c | |
parent | ace39a3ed40cc32ff8d48893173413a7e05b8316 (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.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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)) { |