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.

(cherry picked from commit cb623f8)
ref #18009
  • Loading branch information
timholy authored and tkelman committed Aug 20, 2016
1 parent 1d3d115 commit aeb04ae
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

2 comments on commit aeb04ae

@tkelman
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nanosoldier runbenchmarks(ALL, vs = "@0350e5769b43f56c4c570741b0f5b2edf9399dc7")
aeb04ae vs rc2

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels

Please sign in to comment.