@@ -196,14 +196,18 @@ const andand = AndAnd()
196196broadcasted (:: AndAnd , a, b) = broadcasted ((a, b) -> a && b, a, b)
197197function broadcasted (:: AndAnd , a, bc:: Broadcasted )
198198 bcf = flatten (bc)
199- broadcasted ((a, args... ) -> a && bcf. f (args... ), a, bcf. args... )
199+ # Vararg type signature to specialize on args count. This is necessary for performance
200+ # and innexpensive because this should only ever get called with 1+N = length(bc.args)
201+ broadcasted (((a, args:: Vararg{Any, N} ) where {N}) -> a && bcf. f (args... ), a, bcf. args... )
200202end
201203struct OrOr end
202204const oror = OrOr ()
203205broadcasted (:: OrOr , a, b) = broadcasted ((a, b) -> a || b, a, b)
204206function broadcasted (:: OrOr , a, bc:: Broadcasted )
205207 bcf = flatten (bc)
206- broadcasted ((a, args... ) -> a || bcf. f (args... ), a, bcf. args... )
208+ # Vararg type signature to specialize on args count. This is necessary for performance
209+ # and innexpensive because this should only ever get called with 1+N = length(bc.args)
210+ broadcasted (((a, args:: Vararg{Any, N} ) where {N}) -> a || bcf. f (args... ), a, bcf. args... )
207211end
208212
209213Base. convert (:: Type{Broadcasted{NewStyle}} , bc:: Broadcasted{<:Any,Axes,F,Args} ) where {NewStyle,Axes,F,Args} =
@@ -345,6 +349,7 @@ function flatten(bc::Broadcasted)
345349 # makeargs[3] = ((w, x, y, z)) -> z
346350 makeargs = make_makeargs (bc. args)
347351 f = Base. maybeconstructor (bc. f)
352+ # TODO : consider specializing on args... if performance problems emerge:
348353 newf = (args... ) -> (@inline ; f (prepare_args (makeargs, args)... ))
349354 return Broadcasted (bc. style, newf, args, bc. axes)
350355end
0 commit comments