Skip to content

Commit f5905b1

Browse files
committed
Fix a ReshapedArray indexing performance regression
1 parent 4c17ea3 commit f5905b1

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

base/reshapedarray.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,19 @@ stagedfunction getindex{T,N,P,I}(A::ReshapedArray{T,N,P,I}, indexes::Real...)
118118
for i = 1:npc[end]
119119
j = findlast(npc .< i)
120120
di = i - npc[j]
121-
push!(argsout, Expr(:..., :(tindex[$j][$di])))
121+
push!(argsout, :(tindex[$j][$di]))
122+
end
123+
else
124+
for i = 1:npc[end]
125+
push!(argsout, :(tindex[$i]))
122126
end
123127
end
124128
meta = Expr(:meta, :inline)
125129
ex = length(argsin) == 1 ?
126130
quote
127131
$meta
128-
getindex(A.parent, $(argsin...)...)
132+
tindex = $(argsin...)
133+
getindex(A.parent, $(argsout...))
129134
end :
130135
quote
131136
$meta

test/reshapedarray.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ CC = reshape([1:16;], (2,4,2))
3333
@test isa(CC, Array)
3434

3535
for AT in (ArrayLF, ArrayLS)
36-
@show AT
3736
A = reshape(AT([1:15;]), (3, 5))
3837
@test indextype(A) <: (Reshaped.IndexMD{1,2},)
3938
@test A == AA

0 commit comments

Comments
 (0)