Skip to content

Commit

Permalink
add @inbounds to iterate method for AbstractArray: 3x speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
nsajko committed Jan 21, 2025
1 parent 2e6ffbc commit d221485
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ oneunit(x::AbstractMatrix{T}) where {T} = _one(oneunit(T), x)
function iterate(A::AbstractArray, state=(eachindex(A),))
y = iterate(state...)
y === nothing && return nothing
A[y[1]], (state[1], tail(y)...)
@inbounds A[y[1]], (state[1], tail(y)...)
end

isempty(a::AbstractArray) = (length(a) == 0)
Expand Down

0 comments on commit d221485

Please sign in to comment.