Skip to content

Commit

Permalink
Fix a ReshapedArray indexing performance regression
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Mar 20, 2015
1 parent 4c17ea3 commit f5905b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 7 additions & 2 deletions base/reshapedarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,19 @@ stagedfunction getindex{T,N,P,I}(A::ReshapedArray{T,N,P,I}, indexes::Real...)
for i = 1:npc[end]
j = findlast(npc .< i)
di = i - npc[j]
push!(argsout, Expr(:..., :(tindex[$j][$di])))
push!(argsout, :(tindex[$j][$di]))
end
else
for i = 1:npc[end]
push!(argsout, :(tindex[$i]))
end
end
meta = Expr(:meta, :inline)
ex = length(argsin) == 1 ?
quote
$meta
getindex(A.parent, $(argsin...)...)
tindex = $(argsin...)
getindex(A.parent, $(argsout...))
end :
quote
$meta
Expand Down
1 change: 0 additions & 1 deletion test/reshapedarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ CC = reshape([1:16;], (2,4,2))
@test isa(CC, Array)

for AT in (ArrayLF, ArrayLS)
@show AT
A = reshape(AT([1:15;]), (3, 5))
@test indextype(A) <: (Reshaped.IndexMD{1,2},)
@test A == AA
Expand Down

0 comments on commit f5905b1

Please sign in to comment.