@@ -711,14 +711,18 @@ if VERSION > v"0.5.0-dev+5230"
711
711
sz:: NTuple{N,Int}
712
712
end
713
713
Base. size (P:: ProductIndices ) = P. sz
714
- Base. getindex {_,N} (P:: ProductIndices{_,N} , I:: Vararg{Int, N} ) = Bool ((& )(map (getindex, P. indices, I)... ))
714
+ # This gets passed to map to avoid breaking propagation of inbounds
715
+ Base. @propagate_inbounds propagate_getindex (A, I... ) = A[I... ]
716
+ Base. @propagate_inbounds Base. getindex {_,N} (P:: ProductIndices{_,N} , I:: Vararg{Int, N} ) =
717
+ Bool ((& )(map (propagate_getindex, P. indices, I)... ))
715
718
716
719
immutable MergedIndices{I,N} <: AbstractArray{CartesianIndex{N}, N}
717
720
indices:: I
718
721
sz:: NTuple{N,Int}
719
722
end
720
723
Base. size (M:: MergedIndices ) = M. sz
721
- Base. getindex {_,N} (M:: MergedIndices{_,N} , I:: Vararg{Int, N} ) = CartesianIndex (map (getindex, M. indices, I))
724
+ Base. @propagate_inbounds Base. getindex {_,N} (M:: MergedIndices{_,N} , I:: Vararg{Int, N} ) =
725
+ CartesianIndex (map (propagate_getindex, M. indices, I))
722
726
# Additionally, we optimize bounds checking when using MergedIndices as an
723
727
# array index since checking, e.g., A[1:500, 1:500] is *way* faster than
724
728
# checking an array of 500^2 elements of CartesianIndex{2}. This optimization
0 commit comments