Skip to content

Commit 08e577d

Browse files
committed
Use propagate_inbounds
1 parent a39ec3f commit 08e577d

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/array_partition.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ end
142142
@inline Base.firstindex(A::ArrayPartition) = 1
143143
@inline Base.lastindex(A::ArrayPartition) = length(A)
144144

145-
@inline function Base.getindex(A::ArrayPartition, i::Int)
145+
Base.@propagate_inbounds function Base.getindex(A::ArrayPartition, i::Int)
146146
@boundscheck checkbounds(A, i)
147147
@inbounds for j in 1:length(A.x)
148148
i -= length(A.x[j])
@@ -157,7 +157,7 @@ end
157157
158158
Return the entry at index `j...` of the `i`th partition of `A`.
159159
"""
160-
@inline function Base.getindex(A::ArrayPartition, i::Int, j...)
160+
Base.@propagate_inbounds function Base.getindex(A::ArrayPartition, i::Int, j...)
161161
@boundscheck 0 < i <= length(A.x) || throw(BoundsError(A.x, i))
162162
@inbounds b = A.x[i]
163163
@boundscheck checkbounds(b, j...)
@@ -171,7 +171,7 @@ Return vector with all elements of array partition `A`.
171171
"""
172172
Base.getindex(A::ArrayPartition{T,S}, ::Colon) where {T,S} = T[a for a in Chain(A.x)]
173173

174-
@inline function Base.setindex!(A::ArrayPartition, v, i::Int)
174+
Base.@propagate_inbounds function Base.setindex!(A::ArrayPartition, v, i::Int)
175175
@boundscheck checkbounds(A, i)
176176
@inbounds for j in 1:length(A.x)
177177
i -= length(A.x[j])
@@ -187,7 +187,7 @@ end
187187
188188
Set the entry at index `j...` of the `i`th partition of `A` to `v`.
189189
"""
190-
@inline function Base.setindex!(A::ArrayPartition, v, i::Int, j...)
190+
Base.@propagate_inbounds function Base.setindex!(A::ArrayPartition, v, i::Int, j...)
191191
@boundscheck 0 < i <= length(A.x) || throw(BoundsError(A.x, i))
192192
@inbounds b = A.x[i]
193193
@boundscheck checkbounds(b, j...)

src/vector_of_array.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@ DiffEqArray(vec::AbstractVector{VT},ts::AbstractVector) where {T, N, VT<:Abstrac
3434
@inline Base.IteratorSize(VA::AbstractVectorOfArray) = Base.HasLength()
3535
# Linear indexing will be over the container elements, not the individual elements
3636
# unlike an true AbstractArray
37-
@inline Base.getindex(VA::AbstractVectorOfArray{T, N}, I::Int) where {T, N} = VA.u[I]
38-
@inline Base.getindex(VA::AbstractVectorOfArray{T, N}, I::Colon) where {T, N} = VA.u[I]
39-
@inline Base.getindex(VA::AbstractVectorOfArray{T, N}, I::AbstractArray{Int}) where {T, N} = VectorOfArray(VA.u[I])
40-
@inline Base.getindex(VA::AbstractDiffEqArray{T, N}, I::AbstractArray{Int}) where {T, N} = DiffEqArray(VA.u[I],VA.t[I])
41-
@inline Base.getindex(VA::AbstractVectorOfArray{T, N}, i::Int,::Colon) where {T, N} = [VA.u[j][i] for j in 1:length(VA)]
37+
Base.@propagate_inbounds Base.getindex(VA::AbstractVectorOfArray{T, N}, I::Int) where {T, N} = VA.u[I]
38+
Base.@propagate_inbounds Base.getindex(VA::AbstractVectorOfArray{T, N}, I::Colon) where {T, N} = VA.u[I]
39+
Base.@propagate_inbounds Base.getindex(VA::AbstractVectorOfArray{T, N}, I::AbstractArray{Int}) where {T, N} = VectorOfArray(VA.u[I])
40+
Base.@propagate_inbounds Base.getindex(VA::AbstractDiffEqArray{T, N}, I::AbstractArray{Int}) where {T, N} = DiffEqArray(VA.u[I],VA.t[I])
41+
Base.@propagate_inbounds Base.getindex(VA::AbstractVectorOfArray{T, N}, i::Int,::Colon) where {T, N} = [VA.u[j][i] for j in 1:length(VA)]
4242
Base.@propagate_inbounds function Base.getindex(VA::AbstractVectorOfArray{T,N}, ii::CartesianIndex) where {T, N}
4343
ti = Tuple(ii)
4444
i = first(ti)
4545
jj = CartesianIndex(Base.tail(ti))
4646
return VA.u[i][jj]
4747
end
48-
@inline Base.setindex!(VA::AbstractVectorOfArray{T, N}, v, I::Int) where {T, N} = VA.u[I] = v
49-
@inline Base.setindex!(VA::AbstractVectorOfArray{T, N}, v, I::Colon) where {T, N} = VA.u[I] = v
50-
@inline Base.setindex!(VA::AbstractVectorOfArray{T, N}, v, I::AbstractArray{Int}) where {T, N} = VA.u[I] = v
51-
@inline function Base.setindex!(VA::AbstractVectorOfArray{T, N}, v, i::Int,::Colon) where {T, N}
48+
Base.@propagate_inbounds Base.setindex!(VA::AbstractVectorOfArray{T, N}, v, I::Int) where {T, N} = VA.u[I] = v
49+
Base.@propagate_inbounds Base.setindex!(VA::AbstractVectorOfArray{T, N}, v, I::Colon) where {T, N} = VA.u[I] = v
50+
Base.@propagate_inbounds Base.setindex!(VA::AbstractVectorOfArray{T, N}, v, I::AbstractArray{Int}) where {T, N} = VA.u[I] = v
51+
Base.@propagate_inbounds function Base.setindex!(VA::AbstractVectorOfArray{T, N}, v, i::Int,::Colon) where {T, N}
5252
for j in 1:length(VA)
5353
VA.u[j][i] = v[j]
5454
end
@@ -63,9 +63,9 @@ end
6363

6464
# Interface for the two dimensional indexing, a more standard AbstractArray interface
6565
@inline Base.size(VA::AbstractVectorOfArray) = (size(VA.u[1])..., length(VA.u))
66-
@inline Base.getindex(VA::AbstractVectorOfArray{T, N}, I::Int...) where {T, N} = VA.u[I[end]][Base.front(I)...]
67-
@inline Base.getindex(VA::AbstractVectorOfArray{T, N}, ::Colon, I::Int) where {T, N} = VA.u[I]
68-
@inline Base.setindex!(VA::AbstractVectorOfArray{T, N}, v, I::Int...) where {T, N} = VA.u[I[end]][Base.front(I)...] = v
66+
Base.@propagate_inbounds Base.getindex(VA::AbstractVectorOfArray{T, N}, I::Int...) where {T, N} = VA.u[I[end]][Base.front(I)...]
67+
Base.@propagate_inbounds Base.getindex(VA::AbstractVectorOfArray{T, N}, ::Colon, I::Int) where {T, N} = VA.u[I]
68+
Base.@propagate_inbounds Base.setindex!(VA::AbstractVectorOfArray{T, N}, v, I::Int...) where {T, N} = VA.u[I[end]][Base.front(I)...] = v
6969

7070
# The iterator will be over the subarrays of the container, not the individual elements
7171
# unlike an true AbstractArray

0 commit comments

Comments
 (0)