Skip to content

Commit 1e7a253

Browse files
committed
simplify syntax, less let, etc
1 parent c6fb8dc commit 1e7a253

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

stdlib/Random/src/misc.jl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,12 @@ function shuffle(rng::AbstractRNG, tup::NTuple{N}) where {N}
203203
else
204204
UInt
205205
end
206-
clo = @inbounds let mem = Memory{Ind}(undef, N)
207-
shuffle!(rng, copyto!(mem, Base.OneTo(N))) # just use `randperm!` once it supports `Memory`
208-
let mem = mem, tup = tup
209-
function closure(i::Int)
210-
@inbounds tup[mem[i]]
211-
end
212-
end
206+
# TODO: use `randperm!` instead of `copyto!` from a unit range once `randperm!` supports `Memory`
207+
mem = @inbounds shuffle!(rng, copyto!(Memory{Ind}(undef, N), Base.OneTo(N)))
208+
function closure(i::Int)
209+
@inbounds tup[mem[i]]
213210
end
214-
ntuple(clo, Val{N}())::typeof(tup)
211+
ntuple(closure, Val{N}())::typeof(tup)
215212
end
216213
end
217214

0 commit comments

Comments
 (0)