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
History
File Mode Size
.devcontainer
.github
base
cli
contrib
deps
doc
etc
src
stdlib
test
.buildkite-external-version -rw-r--r-- 5 bytes
.clang-format -rw-r--r-- 3.3 KB
.clangd -rw-r--r-- 114 bytes
.codecov.yml -rw-r--r-- 52 bytes
.git-blame-ignore-revs -rw-r--r-- 371 bytes
.gitattributes -rw-r--r-- 65 bytes
.gitignore -rw-r--r-- 571 bytes
.mailmap -rw-r--r-- 12.7 KB
CITATION.bib -rw-r--r-- 513 bytes
CITATION.cff -rw-r--r-- 940 bytes
CONTRIBUTING.md -rw-r--r-- 23.4 KB
HISTORY.md -rw-r--r-- 372.8 KB
LICENSE.md -rw-r--r-- 1.3 KB
Make.inc -rw-r--r-- 55.9 KB
Makefile -rw-r--r-- 30.2 KB
NEWS.md -rw-r--r-- 11.5 KB
README.md -rw-r--r-- 7.4 KB
THIRDPARTY.md -rw-r--r-- 3.9 KB
VERSION -rw-r--r-- 11 bytes
julia.spdx.json -rw-r--r-- 37.8 KB
pkgimage.mk -rw-r--r-- 5.9 KB
sysimage.mk -rw-r--r-- 4.2 KB
typos.toml -rw-r--r-- 78 bytes

README.md

back to top