Skip to content

Commit 47f3710

Browse files
committed
Don't extend split to tuples (move it into IteratorsMD)
1 parent 2aa0219 commit 47f3710

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

base/multidimensional.jl

+9-8
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,14 @@ simd_index{I<:CartesianIndex{0}}(iter::CartesianRange{I}, ::CartesianIndex, I1::
141141
CartesianIndex((I1+iter.start[1], Ilast.I...))
142142
end
143143

144+
# Split out the first N elements of a tuple
145+
@inline split{N}(t, V::Type{Val{N}}) = _split((), t, V)
146+
@inline _split(tN, trest, V) = _split((tN..., trest[1]), tail(trest), V)
147+
# exit either when we've exhausted the input tuple or when tN has length N
148+
@inline _split{N}(tN::NTuple{N}, ::Tuple{}, ::Type{Val{N}}) = tN, () # ambig.
149+
@inline _split{N}(tN, ::Tuple{}, ::Type{Val{N}}) = tN, ()
150+
@inline _split{N}(tN::NTuple{N}, trest, ::Type{Val{N}}) = tN, trest
151+
144152
end # IteratorsMD
145153

146154
using .IteratorsMD
@@ -163,17 +171,10 @@ end
163171
checkindex(Bool, inds, I[1]) & checkbounds_indices((), tail(I))
164172
end
165173
@inline function checkbounds_indices{N}(inds::Tuple, I::Tuple{AbstractArray{CartesianIndex{N}},Vararg{Any}})
166-
inds1, indsrest = split(inds, Val{N})
174+
inds1, indsrest = IteratorsMD.split(inds, Val{N})
167175
checkindex(Bool, inds1, I[1]) & checkbounds_indices(indsrest, tail(I))
168176
end
169177

170-
@inline split{N}(inds, V::Type{Val{N}}) = _split((), inds, V)
171-
@inline _split(out, indsrest, V) = _split((out..., indsrest[1]), tail(indsrest), V)
172-
# exit either when we've exhausted the input tuple or when it has length N
173-
@inline _split{N}(out::NTuple{N}, ::Tuple{}, ::Type{Val{N}}) = out, () # ambig.
174-
@inline _split{N}(out, ::Tuple{}, ::Type{Val{N}}) = out, ()
175-
@inline _split{N}(out::NTuple{N}, indsrest, ::Type{Val{N}}) = out, indsrest
176-
177178
function checkindex{N}(::Type{Bool}, inds::Tuple, I::AbstractArray{CartesianIndex{N}})
178179
b = true
179180
for i in I

0 commit comments

Comments
 (0)