Skip to content

Commit 54bd72c

Browse files
committed
iterators: merge duplicate iterate methods for Reverse
The method bodies and state optional argument definition are exactly the same.
1 parent a690758 commit 54bd72c

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

base/iterators.jl

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,9 @@ IteratorSize(::Type{Reverse{T}}) where {T} = IteratorSize(T)
120120
IteratorEltype(::Type{Reverse{T}}) where {T} = IteratorEltype(T)
121121
last(r::Reverse) = first(r.itr) # the first shall be last
122122

123-
# reverse-order array iterators: assumes more-specialized Reverse for eachindex
124-
@propagate_inbounds function iterate(A::Reverse{<:AbstractArray}, state=(reverse(eachindex(A.itr)),))
125-
y = iterate(state...)
126-
y === nothing && return y
127-
idx, itrs = y
128-
(A.itr[idx], (state[1], itrs))
129-
end
130-
131123
# Fallback method of `iterate(::Reverse{T})` which assumes the collection has `getindex(::T) and `reverse(eachindex(::T))`
132124
# don't propagate inbounds for this just in case
133-
function iterate(A::Reverse, state=(reverse(eachindex(A.itr)),))
125+
@propagate_inbounds function iterate(A::Reverse, state=(reverse(eachindex(A.itr)),))
134126
y = iterate(state...)
135127
y === nothing && return y
136128
idx, itrs = y

0 commit comments

Comments
 (0)