Skip to content

Commit 6fffd5d

Browse files
authored
fix eachchunk_view performance (#215)
* fix eachchunk_view performance * cleanup * remove unnessary changes
1 parent 44e40a4 commit 6fffd5d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/subarray.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ function eachchunk_view(::Chunked, vv)
2828
if any(ind->!isa(ind,Union{Int,AbstractRange,Colon,AbstractVector{<:Integer}}),pinds)
2929
throw(ArgumentError("Unable to determine chunksize for view of type $(typeof.(pinds))."))
3030
end
31-
iomit = findints(pinds)
3231
chunksparent = eachchunk(parent(vv))
33-
newchunks = [
34-
subsetchunks(chunksparent.chunks[i], pinds[i]) for
35-
i in 1:length(pinds) if !in(i, iomit)
36-
]
37-
return GridChunks(newchunks...)
32+
newchunks = map(chunksparent.chunks, pinds) do ch, pi
33+
pi isa Integer ? nothing : subsetchunks(ch, pi)
34+
end
35+
filteredchunks = reduce(newchunks; init=()) do acc, x
36+
isnothing(x) ? acc : (acc..., x)
37+
end
38+
return GridChunks(filteredchunks...)
3839
end
3940
eachchunk_view(::Unchunked, a) = estimate_chunksize(a)
4041
haschunks(a::SubDiskArray) = haschunks(parent(a.v))

0 commit comments

Comments
 (0)