Skip to content

Commit

Permalink
Merge pull request #13860 from JuliaLang/anj/countnz
Browse files Browse the repository at this point in the history
Don't use _mapreduce for countnz
  • Loading branch information
andreasnoack committed Nov 6, 2015
2 parents bbec291 + 66df1af commit 94f31d1
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions base/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -393,16 +393,8 @@ end

function count(pred, itr)
n = 0
for x in itr
pred(x) && (n += 1)
end
return n
end

function count(pred, A::AbstractArray)
n = 0
@inbounds for a in A
pred(a) && (n += 1)
@inbounds for x in itr
n += pred(x)
end
return n
end
Expand Down

0 comments on commit 94f31d1

Please sign in to comment.