Skip to content

Commit cf9a190

Browse files
committed
Link to specialization tips in the Julia manual
1 parent 621d50a commit cf9a190

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/mapreduce.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,11 @@ reduce(::typeof(hcat), A::StaticArray{<:Tuple,<:StaticVecOrMatLike}) =
202202
## (map)foldl ##
203203
################
204204

205-
@inline mapfoldl(f, op::R, a::StaticArray; init = _InitialValue()) where {R} =
205+
# Using `where {R}` to force specialization. See:
206+
# https://docs.julialang.org/en/v1.5-dev/manual/performance-tips/#Be-aware-of-when-Julia-avoids-specializing-1
207+
# https://github.com/JuliaLang/julia/pull/33917
208+
209+
@inline mapfoldl(f::F, op::R, a::StaticArray; init = _InitialValue()) where {F,R} =
206210
_mapfoldl(f, op, :, init, Size(a), a)
207211
@inline foldl(op::R, a::StaticArray; init = _InitialValue()) where {R} =
208212
_foldl(op, a, :, init)

0 commit comments

Comments
 (0)