Revision 2bd4cf8090f2c651543f562a4c469d73e4b15bd6 authored by Jishnu Bhattacharya on 08 February 2024, 06:22:24 UTC, committed by GitHub on 08 February 2024, 06:22:24 UTC
Currently, views-of-views construct their re-indexed indices by slicing into the parent indices. This PR changes this to use views of the parent indices instead. This makes the operation faster and non-allocating if the `parentindices` for the original view are `Vector`s. ```julia julia> a = rand(200, 200); julia> av = view(a, collect.(axes(a))...); julia> @btime view($av, axes($av)...); 312.393 ns (4 allocations: 3.25 KiB) # master 7.354 ns (0 allocations: 0 bytes) # PR ``` Indexing into the resulting view seems equally fast in simple cases: ```julia julia> av2 = view(av, axes(av)...); julia> @btime sum($av2); 66.883 μs (0 allocations: 0 bytes) # master 66.888 μs (0 allocations: 0 bytes) # PR julia> av2 = view(av, collect.(axes(av))...); julia> @btime sum($av2); 66.886 μs (0 allocations: 0 bytes) # master 66.891 μs (0 allocations: 0 bytes) # PR ``` --------- Co-authored-by: N5N3 <2642243996@qq.com>
1 parent a6ce761
File | Mode | Size |
---|---|---|
man | ||
src | ||
.gitignore | -rw-r--r-- | 55 bytes |
Makefile | -rw-r--r-- | 2.1 KB |
Manifest.toml | -rw-r--r-- | 7.5 KB |
NEWS-update.jl | -rw-r--r-- | 486 bytes |
Project.toml | -rw-r--r-- | 59 bytes |
README.md | -rw-r--r-- | 900 bytes |
make.jl | -rw-r--r-- | 17.6 KB |
Computing file changes ...