Skip to content

Commit

Permalink
Fix missing type parameter in _array_for
Browse files Browse the repository at this point in the history
This fixes a performance regression in the lucompletepiv benchmark triggered by generalizing _array_for to work with indices. This call, first introduced in b363cc7, likely always triggered dynamic method dispatch. The generalization to indices seemed to make that worse.
  • Loading branch information
timholy committed Aug 13, 2016
1 parent 5838a12 commit cb623f8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ else
_default_eltype(itr::ANY) = Any
end

_array_for(T, itr, ::HasLength) = Array{T,1}(Int(length(itr)::Integer))
_array_for(T, itr, ::HasShape) = similar(Array{T}, indices(itr))
_array_for{T}(::Type{T}, itr, ::HasLength) = Array{T,1}(Int(length(itr)::Integer))
_array_for{T}(::Type{T}, itr, ::HasShape) = similar(Array{T}, indices(itr))

function collect(itr::Generator)
isz = iteratorsize(itr.iter)
Expand Down

0 comments on commit cb623f8

Please sign in to comment.