Skip to content

Commit 300f692

Browse files
refactor: avoid allocations when broadcasting over VoA containing SArrays
1 parent fed6857 commit 300f692

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/vector_of_array.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,8 @@ end
666666
if dest[:, i] isa AbstractArray && ArrayInterface.ismutable(dest[:, i])
667667
copyto!(dest[:, i], unpack_voa(bc, i))
668668
else
669-
dest[:, i] = copy(unpack_voa(bc, i))
669+
unpacked = unpack_voa(bc, i)
670+
dest[:, i] = unpacked.f(unpacked.args...)
670671
end
671672
end
672673
dest
@@ -679,7 +680,8 @@ end
679680
if dest[:, i] isa AbstractArray && ArrayInterface.ismutable(dest[:, i])
680681
copyto!(dest[:, i], unpack_voa(bc, i))
681682
else
682-
dest[:, i] = copy(unpack_voa(bc, i))
683+
unpacked = unpack_voa(bc, i)
684+
dest[:, i] = unpacked.f(unpacked.args...)
683685
end
684686
end
685687
dest

0 commit comments

Comments
 (0)