Skip to content

Commit

Permalink
Improve append!!(::SVector, ::SingletonVector) (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Jul 1, 2020
1 parent 9aa6d53 commit d2d83d2
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/NoBang/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,12 @@ append(xs::AbstractVector, ys::AbstractVector) =
vcat(xs, ys)
elseif length(ys) == 0
xs
#=
elseif length(ys) == 1
push(xs, ys[1])
=#
else
# Not so robust:
# append!!(push(xs, ys[1]), @view ys[2:end])
foldl(push!!, (@view ys[2:end]), init=push(xs, ys[1]))
zs = push(xs, ys[1])
length(ys) == 1 && return zs
foldl(push!!, (@view ys[2:end]), init = zs)
end

append(xs::ImmutableContainer, ys) = push(xs, ys...)
Expand Down

0 comments on commit d2d83d2

Please sign in to comment.