Skip to content

Commit e0c007b

Browse files
committed
Apply at-propagate_inbounds to a few nzrange related functions
1 parent 8b03562 commit e0c007b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/higherorderfns.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ const SpBroadcasted2{Style<:SPVM,Axes,F,Args<:Tuple{SparseVecOrMat,SparseVecOrMa
121121
@inline columns(A::AbstractCompressedVector) = 1
122122
@inline columns(A::AbstractSparseMatrixCSC) = axes(A,2)
123123
@inline colrange(A::AbstractCompressedVector, j) = 1:length(nonzeroinds(A))
124-
@inline colrange(A::AbstractSparseMatrixCSC, j) = nzrange(A, j)
124+
Base.@propagate_inbounds colrange(A::AbstractSparseMatrixCSC, j) = nzrange(A, j)
125125
@inline colstartind(A::AbstractCompressedVector, j) = one(indtype(A))
126126
@inline colboundind(A::AbstractCompressedVector, j) = convert(indtype(A), length(nonzeroinds(A)) + 1)
127127
@inline colstartind(A::AbstractSparseMatrixCSC, j) = getcolptr(A)[j]

src/sparsematrix.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ of sparse array `A`. In conjunction with [`nonzeros`](@ref) and
308308
!!! warning
309309
Adding or removing nonzero elements to the matrix may invalidate the `nzrange`, one should not mutate the matrix while iterating.
310310
"""
311-
nzrange(S::AbstractSparseMatrixCSC, col::Integer) = getcolptr(S)[col]:(getcolptr(S)[col+1]-1)
312-
nzrange(S::SparseMatrixCSCColumnSubset, col::Integer) = nzrange(S.parent, S.indices[2][col])
311+
Base.@propagate_inbounds nzrange(S::AbstractSparseMatrixCSC, col::Integer) = getcolptr(S)[col]:(getcolptr(S)[col+1]-1)
312+
Base.@propagate_inbounds nzrange(S::SparseMatrixCSCColumnSubset, col::Integer) = nzrange(S.parent, S.indices[2][col])
313313
nzrange(S::UpperTriangular{<:Any,<:SparseMatrixCSCUnion}, i::Integer) = nzrangeup(S.data, i)
314314
nzrange(S::LowerTriangular{<:Any,<:SparseMatrixCSCUnion}, i::Integer) = nzrangelo(S.data, i)
315315

0 commit comments

Comments
 (0)