@@ -365,7 +365,7 @@ function checkbounds_indices(::Type{Bool}, IA::Tuple, I::Tuple{Any})
365
365
@_inline_meta
366
366
checkbounds_linear_indices (Bool, IA, I[1 ])
367
367
end
368
- function checkbounds_linear_indices (:: Type{Bool} , IA:: Tuple , i)
368
+ function checkbounds_linear_indices (:: Type{Bool} , IA:: Tuple{Vararg{OneTo}} , i)
369
369
@_inline_meta
370
370
if checkindex (Bool, IA[1 ], i)
371
371
return true
@@ -375,6 +375,10 @@ function checkbounds_linear_indices(::Type{Bool}, IA::Tuple, i)
375
375
end
376
376
return false
377
377
end
378
+ function checkbounds_linear_indices (:: Type{Bool} , IA:: Tuple{AbstractUnitRange,Vararg{AbstractUnitRange}} , i)
379
+ @_inline_meta
380
+ checkindex (Bool, IA[1 ], i)
381
+ end
378
382
function checkbounds_linear_indices (:: Type{Bool} , IA:: Tuple , i:: Union{Slice,Colon} )
379
383
partial_linear_indexing_warning_lookup (length (IA))
380
384
true
@@ -853,10 +857,24 @@ _to_subscript_indices{T}(A::AbstractArray{T,0}, i::Int) = () # TODO: REMOVE FOR
853
857
_to_subscript_indices {T} (A:: AbstractArray{T,0} , I:: Int... ) = () # TODO : DEPRECATE FOR #14770
854
858
function _to_subscript_indices {T,N} (A:: AbstractArray{T,N} , I:: Int... ) # TODO : DEPRECATE FOR #14770
855
859
@_inline_meta
856
- J, _ = IteratorsMD. split (I, Val{N}) # (maybe) drop any trailing indices
857
- sz = _remaining_size (J, size (A)) # compute trailing size (overlapping the final index)
860
+ J, Jrem = IteratorsMD. split (I, Val{N})
861
+ _to_subscript_indices (A, J, Jrem)
862
+ end
863
+ _to_subscript_indices (A:: AbstractArray , J:: Tuple , Jrem:: Tuple{} ) =
864
+ __to_subscript_indices (A, indices (A), J, Jrem)
865
+ # We allow partial linear indexing deprecation for OneTo arrays
866
+ function __to_subscript_indices (A:: AbstractArray , :: Tuple{Vararg{OneTo}} , J:: Tuple , Jrem:: Tuple{} )
867
+ @_inline_meta
868
+ sz = _remaining_size (J, indices (A)) # compute trailing size (overlapping the final index)
858
869
(front (J)... , _unsafe_ind2sub (sz, last (J))... ) # (maybe) extend the last index
859
870
end
871
+ # After the partial linear indexing deprecation is removed, this next method can
872
+ # become the new normal. For now, it's limited to non-OneTo arrays.
873
+ function __to_subscript_indices (A:: AbstractArray , :: Tuple{AbstractUnitRange,Vararg{AbstractUnitRange}} , J:: Tuple , Jrem:: Tuple{} )
874
+ @_inline_meta
875
+ (J... , map (first, tail (_remaining_size (J, indices (A))))... )
876
+ end
877
+ _to_subscript_indices (A, J:: Tuple , Jrem:: Tuple ) = J # already bounds-checked, safe to drop
860
878
_to_subscript_indices {T,N} (A:: AbstractArray{T,N} , I:: Vararg{Int,N} ) = I
861
879
_remaining_size (:: Tuple{Any} , t:: Tuple ) = t
862
880
_remaining_size (h:: Tuple , t:: Tuple ) = (@_inline_meta ; _remaining_size (tail (h), tail (t)))
0 commit comments