Skip to content

Commit c25c2bc

Browse files
matthias314N5N3
authored and
KristofferC
committed
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]> (cherry picked from commit 1543cdd)
1 parent ab27a43 commit c25c2bc

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

base/abstractarray.jl

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

0 commit comments

Comments
 (0)