Skip to content

Commit 780d5b5

Browse files
committed
Fix more allocation tests in higherorderfns.jl (by @timholy).
1 parent 6cf55aa commit 780d5b5

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

base/broadcast.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ longest(::Tuple{}, ::Tuple{}) = ()
258258
# combine_styles operates on values (arbitrarily many)
259259
combine_styles(c) = result_style(BroadcastStyle(typeof(c)))
260260
combine_styles(c1, c2) = result_style(combine_styles(c1), combine_styles(c2))
261-
combine_styles(c1, c2, cs...) = result_style(combine_styles(c1), combine_styles(c2, cs...))
261+
@inline combine_styles(c1, c2, cs...) = result_style(combine_styles(c1), combine_styles(c2, cs...))
262262

263263
# result_style works on types (singletons and pairs), and leverages `BroadcastStyle`
264264
result_style(s::BroadcastStyle) = s
@@ -442,8 +442,8 @@ Note that `dest` is only used to store the result, and does not supply
442442
arguments to `f` unless it is also listed in the `As`,
443443
as in `broadcast!(f, A, A, B)` to perform `A[:] = broadcast(f, A, B)`.
444444
"""
445-
@inline broadcast!(f, dest, As...) = broadcast!(f, dest, combine_styles(As...), As...)
446-
@inline broadcast!(f, dest, ::BroadcastStyle, As...) = broadcast!(f, dest, nothing, As...)
445+
@inline broadcast!(f::Tf, dest, As::Vararg{Any,N}) where {Tf,N} = broadcast!(f, dest, combine_styles(As...), As...)
446+
@inline broadcast!(f::Tf, dest, ::BroadcastStyle, As::Vararg{Any,N}) where {Tf,N} = broadcast!(f, dest, nothing, As...)
447447

448448
# Default behavior (separated out so that it can be called by users who want to extend broadcast!).
449449
@inline function broadcast!(f, dest, ::Void, As::Vararg{Any, N}) where N

base/sparse/higherorderfns.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1021,15 +1021,15 @@ function spbroadcast_args!(f::Tf, C, ::SPVM, A::SparseVecOrMat, Bs::Vararg{Spars
10211021
return fpreszeros ? _broadcast_zeropres!(f, C, A, Bs...) :
10221022
_broadcast_notzeropres!(f, fofzeros, C, A, Bs...)
10231023
end
1024-
function spbroadcast_args!(f, dest, ::SPVM, mixedsrcargs::Vararg{Any,N}) where N
1024+
function spbroadcast_args!(f::Tf, dest, ::SPVM, mixedsrcargs::Vararg{Any,N}) where {Tf,N}
10251025
# mixedsrcargs contains nothing but SparseVecOrMat and scalars
10261026
parevalf, passedsrcargstup = capturescalars(f, mixedsrcargs)
10271027
return broadcast!(parevalf, dest, passedsrcargstup...)
10281028
end
1029-
function spbroadcast_args!(f, dest, ::PromoteToSparse, mixedsrcargs::Vararg{Any,N}) where N
1029+
function spbroadcast_args!(f::Tf, dest, ::PromoteToSparse, mixedsrcargs::Vararg{Any,N}) where {Tf,N}
10301030
broadcast!(f, dest, map(_sparsifystructured, mixedsrcargs)...)
10311031
end
1032-
function spbroadcast_args!(f, dest, ::Any, mixedsrcargs::Vararg{Any,N}) where N
1032+
function spbroadcast_args!(f::Tf, dest, ::Any, mixedsrcargs::Vararg{Any,N}) where {Tf,N}
10331033
# Fallback. From a performance perspective would it be best to densify?
10341034
Broadcast._broadcast!(f, dest, mixedsrcargs...)
10351035
end

0 commit comments

Comments
 (0)