Skip to content

append_chunk: do not make a copy if the whole chunk is appended. #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/BufferStream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ function append_chunk(bs::BufferStream, data::AbstractVector{UInt8})
continue
end
bytes_to_write = min(space_available, length(data) - data_written)
push!(bs.chunks, data[data_written+1:data_written+bytes_to_write])
if data_written == 0 && bytes_to_write == length(data)
push!(bs.chunks, data)
else
push!(bs.chunks, data[data_written+1:data_written+bytes_to_write])
end
# Notify someone who was waiting for some data
lock(bs.read_cond) do
notify(bs.read_cond; all=false)
Expand Down
Loading