Skip to content

Commit 2ca85f0

Browse files
committed
Specialize Base.copy for VectorOfArrays
1 parent b0496e5 commit 2ca85f0

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/vector_of_arrays.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,11 @@ function Base.vcat(Vs::(VectorOfArrays{U,N} where U)...) where {N}
345345
end
346346

347347

348+
function Base.copy(V::VectorOfArrays)
349+
VectorOfArrays(copy(V.data), copy(V.elem_ptr), copy(V.kernel_size), no_consistency_checks)
350+
end
351+
352+
348353
Base.@propagate_inbounds function Base.unsafe_view(A::VectorOfArrays, idxs::AbstractUnitRange{<:Integer})
349354
from = first(idxs)
350355
to = last(idxs)

test/vector_of_arrays.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ using ArraysOfArrays: full_consistency_checks, append_elemptr!
100100
end
101101

102102

103+
@testset "copy" begin
104+
A = ref_AoA3(Float32, 3);
105+
B = VectorOfArrays(A);
106+
107+
@test typeof(@inferred copy(A)) == typeof(A)
108+
@test copy(A) == A
109+
@test copy(A) == B
110+
end
111+
112+
103113
@testset "examples" begin
104114
VA = VectorOfArrays{Float64, 2}()
105115

0 commit comments

Comments
 (0)