Skip to content

Commit

Permalink
Rename: collect_to_structarray! -> _collect_to_structarray!
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Dec 18, 2019
1 parent 6673195 commit eb3c6a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/collect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ function collect_structarray(itr, elem, sz::Union{Base.HasShape, Base.HasLength}
S = typeof(el)
dest = initializer(S, (length(itr),))
dest[1] = el
v = collect_to_structarray!(dest, itr, 2, i)
v = _collect_to_structarray!(dest, itr, 2, i)
_reshape(v, itr, sz)
end

function collect_to_structarray!(dest::AbstractArray, itr, offs, st)
function _collect_to_structarray!(dest::AbstractArray, itr, offs, st)
# collect to dest array, checking the type of each result. if a result does not
# match, widen the result type and re-dispatch.
i = offs
Expand All @@ -77,7 +77,7 @@ function collect_to_structarray!(dest::AbstractArray, itr, offs, st)
else
new = widenstructarray(dest, i, el)
@inbounds new[i] = el
return collect_to_structarray!(new, itr, i+1, st)
return _collect_to_structarray!(new, itr, i+1, st)
end
end
return dest
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ collect_structarray_rec(t) = collect_structarray(t, initializer = initializer)
el, st = iterate(itr)
dest = initializer(typeof(el), (3,))
dest[1] = el
@inferred StructArrays.collect_to_structarray!(dest, itr, 2, st)
@inferred StructArrays._collect_to_structarray!(dest, itr, 2, st)

v = [(a = 1, b = 2), (a = 1.2, b = 3)]
@test collect_structarray_rec(v) == StructArray((a = [1, 1.2], b = Int[2, 3]))
Expand Down

0 comments on commit eb3c6a8

Please sign in to comment.