Skip to content

Commit 3b88f3c

Browse files
committed
Use generic fallback for arrays with !(eltype >: Missing)
1 parent e19f39c commit 3b88f3c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

base/missing.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@ function iterate(itr::SkipMissing, state...)
190190
end
191191

192192
# Optimized mapreduce implementation
193-
mapreduce(f, op, itr::SkipMissing{<:AbstractArray}) = _mapreduce(f, op, IndexStyle(itr.x), itr)
193+
# The generic method is faster when !(eltype(A) >: Missing) since it does not need
194+
# additional loops to identify the two first non-missing values of each block
195+
mapreduce(f, op, itr::SkipMissing{<:AbstractArray}) =
196+
_mapreduce(f, op, IndexStyle(itr.x), eltype(itr.x) >: Missing ? itr : itr.x)
194197

195198
function _mapreduce(f, op, ::IndexLinear, itr::SkipMissing{<:AbstractArray})
196199
A = itr.x

0 commit comments

Comments
 (0)