Skip to content

Commit

Permalink
remove looping in map!
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Sep 21, 2018
1 parent 7898e02 commit e283ff5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/mapreduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ end
_map!(f, dest, same_size(dest, a, b), a, b)
end


@generated function _map!(f, dest, ::Size{S}, a::StaticArray...) where {S}
tmp = [:(a[$j][i]) for j 1:length(a)]
exprs = Vector{Expr}(undef, prod(S))
for i 1:prod(S)
tmp = [:(a[$j][$i]) for j 1:length(a)]
exprs[i] = :(dest[$i] = f($(tmp...)))
end
return quote
@_inline_meta
@inbounds @simd for i 1:$(prod(S))
dest[i] = f($(tmp...))
end
return dest
@inbounds $(Expr(:block, exprs...))
end
end

Expand Down

0 comments on commit e283ff5

Please sign in to comment.