Skip to content

Commit

Permalink
Add 1-index specialization of checkbounds
Browse files Browse the repository at this point in the history
This seems important for good codegen with LinearSlow indexing
  • Loading branch information
timholy committed Jul 11, 2016
1 parent 938b56d commit eff2593
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ function checkbounds(::Type{Bool}, A::AbstractArray, I::AbstractArray{Bool})
@_inline_meta
checkbounds_logical(A, I)
end
function checkbounds(::Type{Bool}, A::AbstractArray, i)
@_inline_meta
checkbounds_indices(indices(A), (i,))
end

# checkbounds_indices iteratively consumes elements of the
# indices-tuple of an arrray and the indices-tuple supplied by the
Expand Down Expand Up @@ -249,6 +253,10 @@ function checkbounds(A::AbstractArray, I...)
@_inline_meta
checkbounds(Bool, A, I...) || throw_boundserror(A, I)
end
function checkbounds(A::AbstractArray, i)
@_inline_meta
checkbounds(Bool, A, i) || throw_boundserror(A, (i,))
end
checkbounds(A::AbstractArray) = checkbounds(A, 1) # 0-d case

# See also specializations in multidimensional
Expand Down

0 comments on commit eff2593

Please sign in to comment.