Skip to content

Commit 91effc4

Browse files
fredrikekregiordano
authored andcommitted
append_chunk: do not make a copy if the whole chunk is appended.
1 parent 5cb34d2 commit 91effc4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/BufferStream.jl

+5-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ function append_chunk(bs::BufferStream, data::AbstractVector{UInt8})
6767
continue
6868
end
6969
bytes_to_write = min(space_available, length(data) - data_written)
70-
push!(bs.chunks, data[data_written+1:data_written+bytes_to_write])
70+
if data_written == 0 && bytes_to_write == length(data)
71+
push!(bs.chunks, data)
72+
else
73+
push!(bs.chunks, data[data_written+1:data_written+bytes_to_write])
74+
end
7175
# Notify someone who was waiting for some data
7276
lock(bs.read_cond) do
7377
notify(bs.read_cond; all=false)

0 commit comments

Comments
 (0)