@@ -132,6 +132,20 @@ for ItrT = (Tuple,Any)
132132 end
133133end
134134
135+ # When the function is side effect-free, we may avoid short-circuiting to help
136+ # vectorize the loop.
137+ function _any (:: typeof (identity), itr:: Tuple{Vararg{Bool}} , :: Colon )
138+ @_terminates_locally_meta
139+ r = false
140+ for i in eachindex (itr)
141+ # Avoid bounds checking to help vectorization. Use `getfield` directly,
142+ # instead of `@inbounds itr[i]`, for better effects.
143+ v = getfield (itr, i, false )
144+ r |= v
145+ end
146+ r
147+ end
148+
135149# Specialized versions of any(f, ::Tuple)
136150# We fall back to the for loop implementation all elements have the same type or
137151# if the tuple is too large.
@@ -205,6 +219,20 @@ for ItrT = (Tuple,Any)
205219 end
206220end
207221
222+ # When the function is side effect-free, we may avoid short-circuiting to help
223+ # vectorize the loop.
224+ function _all (:: typeof (identity), itr:: Tuple{Vararg{Bool}} , :: Colon )
225+ @_terminates_locally_meta
226+ r = true
227+ for i in eachindex (itr)
228+ # Avoid bounds checking to help vectorization. Use `getfield` directly,
229+ # instead of `@inbounds itr[i]`, for better effects.
230+ v = getfield (itr, i, false )
231+ r &= v
232+ end
233+ r
234+ end
235+
208236# Specialized versions of all(f, ::Tuple),
209237# This is similar to any(f, ::Tuple) defined above.
210238function all (f, itr:: Tuple )
227255 return _all_tuple (f, anymissing, rest... )
228256end
229257@inline _all_tuple (f, anymissing) = anymissing ? missing : true
230-
231- all (:: Tuple{Missing} ) = missing
0 commit comments