Skip to content

Commit 4577162

Browse files
committed
simplify using randperm! as per rfourqet
1 parent 77c6d62 commit 4577162

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

stdlib/Random/src/misc.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ function shuffle(rng::AbstractRNG, tup::(Tuple{Vararg{T, N}} where {T})) where {
187187
if tup isa Tuple{Any, Vararg}
188188
@inline let # `@inline` and `@inbounds` are here to help escape analysis
189189
clo = @inbounds let mem = Memory{UInt16}(undef, N) # use `UInt16` to save stack space/prevent heap allocation
190-
copyto!(mem, Base.OneTo(N))
191-
shuffle!(rng, mem)
190+
randperm!(rng, mem)
192191
let mem = mem, tup = tup
193192
function closure(i::Int)
194193
@inbounds tup[mem[i]]

0 commit comments

Comments
 (0)