Skip to content

Commit

Permalink
Force specialization on operator arguments for mapfoldl_impl (#33917)
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy authored Nov 22, 2019
1 parent e706e83 commit 9bac3a9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ mul_prod(x::Real, y::Real)::Real = x * y

## foldl && mapfoldl

function mapfoldl_impl(f, op, nt::NamedTuple{(:init,)}, itr, i...)
function mapfoldl_impl(f::F, op::OP, nt::NamedTuple{(:init,)}, itr, i...) where {F,OP}
init = nt.init
# Unroll the while loop once; if init is known, the call to op may
# be evaluated at compile time
Expand All @@ -51,7 +51,7 @@ function mapfoldl_impl(f, op, nt::NamedTuple{(:init,)}, itr, i...)
return v
end

function mapfoldl_impl(f, op, nt::NamedTuple{()}, itr)
function mapfoldl_impl(f::F, op::OP, nt::NamedTuple{()}, itr) where {F,OP}
y = iterate(itr)
if y === nothing
return Base.mapreduce_empty_iter(f, op, itr, IteratorEltype(itr))
Expand Down

0 comments on commit 9bac3a9

Please sign in to comment.