Skip to content

Commit

Permalink
ensure require_one_based_indexing can constant-fold for ranges (#40358)
Browse files Browse the repository at this point in the history
Refs performance issue noted in #38527
  • Loading branch information
vtjnash authored Apr 6, 2021
1 parent fedefe9 commit bda6b94
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ end
Return `true` if the indices of `A` start with something other than 1 along any axis.
If multiple arguments are passed, equivalent to `has_offset_axes(A) | has_offset_axes(B) | ...`.
"""
has_offset_axes(A) = _tuple_any(x->Int(first(x))::Int != 1, axes(A))
has_offset_axes(A) = _tuple_any(x->Int(first(x))::Int != 1, axes(A))
has_offset_axes(A::AbstractVector) = Int(firstindex(A))::Int != 1 # improve performance of a common case (ranges)
has_offset_axes(A...) = _tuple_any(has_offset_axes, A)
has_offset_axes(::Colon) = false

Expand Down

0 comments on commit bda6b94

Please sign in to comment.