|
2 | 2 | """
|
3 | 3 | OptionallyStaticUnitRange(start, stop, check_lower_bound=True(), check_upper_bound=True()) <: AbstractUnitRange{Int}
|
4 | 4 |
|
5 |
| -Similar to `UnitRange` except each field may be an `Int` or `StaticInt`. An |
6 |
| -`OptionallyStaticUnitRange` is intended to be constructed internally from other valid |
7 |
| -indices. Therefore, users should not expect the same checks are used to ensure construction |
8 |
| -of a valid `OptionallyStaticUnitRange` as a `UnitRange`. `check_lower_bound` and |
9 |
| -`check_upper_bound` determine whether `start` and `stop` are bounds checked when |
10 |
| -`OptionallyStaticUnitRange` is used as an index. |
| 5 | +Similar to `UnitRange` except each field may be an `Int` or `StaticInt`. `check_lower_bound` |
| 6 | +and `check_upper_bound` determine whether `start` and `stop` are bounds checked when |
| 7 | +`OptionallyStaticUnitRange` is used as an index. This type is intended to be constructed |
| 8 | +internally from other valid indices. Therefore, users should not expect the same checks are |
| 9 | +used to ensure construction of a valid `OptionallyStaticUnitRange` as a `UnitRange`. |
| 10 | +
|
| 11 | +!!! warning |
| 12 | +
|
| 13 | + Manually setting `check_lower_bound` and `check_upper_bound` to `False()` has similar |
| 14 | + behavior as `@inbounds` and may result in incorrect results/crashes/corruption. |
11 | 15 | """
|
12 | 16 | struct OptionallyStaticUnitRange{F<:CanonicalInt,L<:CanonicalInt,CLB<:Union{False,True},CUB<:Union{False,True}} <: AbstractUnitRange{Int}
|
13 | 17 | start::F
|
@@ -157,7 +161,7 @@ ArrayInterfaceCore.known_last(::Type{<:OptionallyStaticStepRange{<:Any,<:Any,Sta
|
157 | 161 | return known_first(r)
|
158 | 162 | end
|
159 | 163 | end
|
160 |
| -function Base.step(r::OptionallyStaticStepRange)::Int |
| 164 | +@inline function Base.step(r::OptionallyStaticStepRange)::Int |
161 | 165 | if known_step(r) === nothing
|
162 | 166 | return getfield(r, :step)
|
163 | 167 | else
|
|
0 commit comments