Skip to content

Commit

Permalink
fix perf regression for bitrand (#26529)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC authored Mar 22, 2018
1 parent ef0ef80 commit 6647086
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions stdlib/Random/src/Random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,18 @@ rand(rng::AbstractRNG, ::UniformT{T}) where {T} = rand(rng, T)

#### scalars

rand(rng::AbstractRNG, X) = rand(rng, Sampler(rng, X, Val(1)))
rand(rng::AbstractRNG=GLOBAL_RNG, ::Type{X}=Float64) where {X} =
rand(rng, Sampler(rng, X, Val(1)))
rand(rng::AbstractRNG, X) = rand(rng, Sampler(rng, X, Val(1)))
rand(rng::AbstractRNG=GLOBAL_RNG, ::Type{X}=Float64) where {X} = rand(rng, Sampler(rng, X, Val(1)))

rand(X) = rand(GLOBAL_RNG, X)
rand(X) = rand(GLOBAL_RNG, X)
rand(::Type{X}) where {X} = rand(GLOBAL_RNG, X)

#### arrays

rand!(A::AbstractArray{T}, X) where {T} = rand!(GLOBAL_RNG, A, X)
rand!(A::AbstractArray{T}, X) where {T} = rand!(GLOBAL_RNG, A, X)
rand!(A::AbstractArray{T}, ::Type{X}=T) where {T,X} = rand!(GLOBAL_RNG, A, X)

rand!(rng::AbstractRNG, A::AbstractArray{T}, X) where {T} = rand!(rng, A, Sampler(rng, X))
rand!(rng::AbstractRNG, A::AbstractArray{T}, X) where {T} = rand!(rng, A, Sampler(rng, X))
rand!(rng::AbstractRNG, A::AbstractArray{T}, ::Type{X}=T) where {T,X} = rand!(rng, A, Sampler(rng, X))

function rand!(rng::AbstractRNG, A::AbstractArray{T}, sp::Sampler) where T
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Random/src/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## rand!(::BitArray) && bitrand

function rand!(rng::AbstractRNG, B::BitArray)
function rand!(rng::AbstractRNG, B::BitArray, ::SamplerType{Bool})
isempty(B) && return B
Bc = B.chunks
rand!(rng, Bc)
Expand Down

0 comments on commit 6647086

Please sign in to comment.