Commit 561e5c8
Fast bounds-check for CartesianIndex ranges (#55596)
`StepRangeLen{<:CartesianIndex}` indices have been supported since
v1.11, but bounds-checking for such indices currently falls back to
iterating over the entire range. This PR adds a quick `checkindex` for
such ranges.
The performance improvement as a consequence:
```julia
julia> D = Diagonal(1:10_000);
julia> @Btime checkbounds($D, diagind($D, IndexCartesian()));
6.697 μs (0 allocations: 0 bytes) # nightly, O(n)
4.044 ns (0 allocations: 0 bytes) # This PR, O(1)
```
(cherry picked from commit 6440292)1 parent d6fca15 commit 561e5c8
File tree
2 files changed
+7
-0
lines changed- base
- stdlib/LinearAlgebra/test
2 files changed
+7
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
693 | 693 | | |
694 | 694 | | |
695 | 695 | | |
| 696 | + | |
| 697 | + | |
696 | 698 | | |
697 | 699 | | |
698 | 700 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1312 | 1312 | | |
1313 | 1313 | | |
1314 | 1314 | | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
1315 | 1320 | | |
0 commit comments