Skip to content

Commit eff2593

Browse files
committed
Add 1-index specialization of checkbounds
This seems important for good codegen with LinearSlow indexing
1 parent 938b56d commit eff2593

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

base/abstractarray.jl

+8
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ function checkbounds(::Type{Bool}, A::AbstractArray, I::AbstractArray{Bool})
203203
@_inline_meta
204204
checkbounds_logical(A, I)
205205
end
206+
function checkbounds(::Type{Bool}, A::AbstractArray, i)
207+
@_inline_meta
208+
checkbounds_indices(indices(A), (i,))
209+
end
206210

207211
# checkbounds_indices iteratively consumes elements of the
208212
# indices-tuple of an arrray and the indices-tuple supplied by the
@@ -249,6 +253,10 @@ function checkbounds(A::AbstractArray, I...)
249253
@_inline_meta
250254
checkbounds(Bool, A, I...) || throw_boundserror(A, I)
251255
end
256+
function checkbounds(A::AbstractArray, i)
257+
@_inline_meta
258+
checkbounds(Bool, A, i) || throw_boundserror(A, (i,))
259+
end
252260
checkbounds(A::AbstractArray) = checkbounds(A, 1) # 0-d case
253261

254262
# See also specializations in multidimensional

0 commit comments

Comments
 (0)