Skip to content

Commit

Permalink
Optimize compaction of Reader::data_stream (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
fintelia authored Nov 26, 2023
1 parent b93777c commit f80dfe9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/decoder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,9 @@ impl<R: Read> Reader<R> {

// Clear the current buffer before appending more data.
if self.prev_start > 0 {
self.data_stream.drain(..self.prev_start).for_each(drop);
self.data_stream.copy_within(self.prev_start.., 0);
self.data_stream
.truncate(self.data_stream.len() - self.prev_start);
self.current_start -= self.prev_start;
self.prev_start = 0;
}
Expand Down

0 comments on commit f80dfe9

Please sign in to comment.