Skip to content

Commit

Permalink
Fix sizehint for VectorOfArrays(#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrhck authored Nov 3, 2023
1 parent 3a6f5ba commit 3212544
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/vector_of_arrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ end


function Base.sizehint!(A::VectorOfArrays{T,N}, n, s::Dims{N}) where {T,N}
sizehint!(A.data, n * mul(s))
sizehint!(A.data, n * prod(s))
sizehint!(A.elem_ptr, n + 1)
sizehint!(A.kernel_size, n)
A
Expand Down
6 changes: 6 additions & 0 deletions test/vector_of_arrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -324,4 +324,10 @@ using ArraysOfArrays: full_consistency_checks, append_elemptr!, element_ptr
@test @inferred(do_map(identity, A)) === A
end
end

@testset "resize" begin
A1 = VectorOfArrays{Float64, 1}(ref_AoA1(Float64, 3))
sizehint!(A1, 5, (10000,))
@test ccall(:jl_array_size, Int, (Any, UInt), A1.data, 1) == 5*10000
end
end

0 comments on commit 3212544

Please sign in to comment.