Skip to content
This repository was archived by the owner on Apr 12, 2019. It is now read-only.

Commit 0c63ec7

Browse files
authored
Merge pull request JuliaLang#24481 from JuliaLang/yyc/iterator-bounds
Mark `next` for iterator wrapper as `propagate_inbounds`
2 parents c8d52d2 + 59f8998 commit 0c63ec7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Diff for: base/iterators.jl

+8-8
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ enumerate(iter) = Enumerate(iter)
110110
length(e::Enumerate) = length(e.itr)
111111
size(e::Enumerate) = size(e.itr)
112112
@inline start(e::Enumerate) = (1, start(e.itr))
113-
@inline function next(e::Enumerate, state)
113+
@propagate_inbounds function next(e::Enumerate, state)
114114
n = next(e.itr,state[2])
115115
(state[1],n[1]), (state[1]+1,n[2])
116116
end
@@ -225,7 +225,7 @@ size(z::Zip1) = size(z.a)
225225
indices(z::Zip1) = indices(z.a)
226226
eltype(::Type{Zip1{I}}) where {I} = Tuple{eltype(I)}
227227
@inline start(z::Zip1) = start(z.a)
228-
@inline function next(z::Zip1, st)
228+
@propagate_inbounds function next(z::Zip1, st)
229229
n = next(z.a,st)
230230
return ((n[1],), n[2])
231231
end
@@ -244,7 +244,7 @@ size(z::Zip2) = promote_shape(size(z.a), size(z.b))
244244
indices(z::Zip2) = promote_shape(indices(z.a), indices(z.b))
245245
eltype(::Type{Zip2{I1,I2}}) where {I1,I2} = Tuple{eltype(I1), eltype(I2)}
246246
@inline start(z::Zip2) = (start(z.a), start(z.b))
247-
@inline function next(z::Zip2, st)
247+
@propagate_inbounds function next(z::Zip2, st)
248248
n1 = next(z.a,st[1])
249249
n2 = next(z.b,st[2])
250250
return ((n1[1], n2[1]), (n1[2], n2[2]))
@@ -294,7 +294,7 @@ size(z::Zip) = promote_shape(size(z.a), size(z.z))
294294
indices(z::Zip) = promote_shape(indices(z.a), indices(z.z))
295295
eltype(::Type{Zip{I,Z}}) where {I,Z} = tuple_type_cons(eltype(I), eltype(Z))
296296
@inline start(z::Zip) = tuple(start(z.a), start(z.z))
297-
@inline function next(z::Zip, st)
297+
@propagate_inbounds function next(z::Zip, st)
298298
n1 = next(z.a, st[1])
299299
n2 = next(z.z, st[2])
300300
(tuple(n1[1], n2[1]...), (n1[2], n2[2]))
@@ -401,7 +401,7 @@ julia> collect(Iterators.rest([1,2,3,4], 2))
401401
rest(itr,state) = Rest(itr,state)
402402

403403
start(i::Rest) = i.st
404-
next(i::Rest, st) = next(i.itr, st)
404+
@propagate_inbounds next(i::Rest, st) = next(i.itr, st)
405405
done(i::Rest, st) = done(i.itr, st)
406406

407407
eltype(::Type{Rest{I}}) where {I} = eltype(I)
@@ -490,7 +490,7 @@ length(t::Take) = _min_length(t.xs, 1:t.n, iteratorsize(t.xs), HasLength())
490490

491491
start(it::Take) = (it.n, start(it.xs))
492492

493-
function next(it::Take, state)
493+
@propagate_inbounds function next(it::Take, state)
494494
n, xs_state = state
495495
v, xs_state = next(it.xs, xs_state)
496496
return v, (n - 1, xs_state)
@@ -557,7 +557,7 @@ function start(it::Drop)
557557
xs_state
558558
end
559559

560-
next(it::Drop, state) = next(it.xs, state)
560+
@propagate_inbounds next(it::Drop, state) = next(it.xs, state)
561561
done(it::Drop, state) = done(it.xs, state)
562562

563563
# Cycle an iterator forever
@@ -833,7 +833,7 @@ function start(f::Flatten)
833833
return s, inner, s2
834834
end
835835

836-
@inline function next(f::Flatten, state)
836+
@propagate_inbounds function next(f::Flatten, state)
837837
s, inner, s2 = state
838838
val, s2 = next(inner, s2)
839839
while done(inner, s2) && !done(f.it, s)

0 commit comments

Comments
 (0)