Skip to content

Commit bf57c4d

Browse files
committed
iterators: merge duplicate iterate methods for Reverse
The method bodies and state optional argument definition are exactly the same. The only difference between the two methods, is that the more specific method, for `Reverse{<:AbstractArray}`, had a `@propagate_inbounds` annotation. I simply deleted the more specific method, together with the annotation. Deleting the annotation is consistent with the fact that the `iterate(::AbstractArray)` method, in abstractarray.jl, has no such annotation.
1 parent b265dba commit bf57c4d

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

base/iterators.jl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,6 @@ 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
133125
function iterate(A::Reverse, state=(reverse(eachindex(A.itr)),))

0 commit comments

Comments
 (0)