Skip to content

Commit

Permalink
Simplify first index in FastContiguousSubArray definition (#56491)
Browse files Browse the repository at this point in the history
Since `Slice <: AbstractUnitRange` and `Union{Slice, AbstractUnitRange}
== AbstractUnitRange`, we may simplify the first index.
  • Loading branch information
jishnub authored Nov 8, 2024
1 parent 0e811e4 commit a005c07
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion base/subarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ end

# We can avoid a multiplication if the first parent index is a Colon or AbstractUnitRange,
# or if all the indices are scalars, i.e. the view is for a single value only
FastContiguousSubArray{T,N,P,I<:Union{Tuple{Union{Slice, AbstractUnitRange}, Vararg{Any}},
FastContiguousSubArray{T,N,P,I<:Union{Tuple{AbstractUnitRange, Vararg{Any}},
Tuple{Vararg{ScalarIndex}}}} = SubArray{T,N,P,I,true}

@inline _reindexlinear(V::FastContiguousSubArray, i::Int) = V.offset1 + i
Expand Down

0 comments on commit a005c07

Please sign in to comment.