Skip to content

Commit 1543cdd

Browse files
matthias314N5N3
andauthored
Faster iteration over non-offset AbstractVector (#48720)
This change simplifies the boundscheck in loop as LLVM would lift the const subtraction. Simd block would be generated in more cases. Co-authored-by: N5N3 <[email protected]>
1 parent a1b546a commit 1543cdd

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

base/abstractarray.jl

+2
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,8 @@ false
767767
checkindex(::Type{Bool}, inds::AbstractUnitRange, i) =
768768
throw(ArgumentError("unable to check bounds for indices of type $(typeof(i))"))
769769
checkindex(::Type{Bool}, inds::AbstractUnitRange, i::Real) = (first(inds) <= i) & (i <= last(inds))
770+
checkindex(::Type{Bool}, inds::IdentityUnitRange, i::Real) = checkindex(Bool, inds.indices, i)
771+
checkindex(::Type{Bool}, inds::OneTo{T}, i::T) where {T<:BitInteger} = unsigned(i - one(i)) < unsigned(last(inds))
770772
checkindex(::Type{Bool}, inds::AbstractUnitRange, ::Colon) = true
771773
checkindex(::Type{Bool}, inds::AbstractUnitRange, ::Slice) = true
772774
function checkindex(::Type{Bool}, inds::AbstractUnitRange, r::AbstractRange)

0 commit comments

Comments
 (0)