Skip to content

Commit

Permalink
Fix the actual god damned bottleneck, because calling .truncate() act…
Browse files Browse the repository at this point in the history
…ually tries to drop every byte in the array. Telling the vector to forget it's contents is a better approach
  • Loading branch information
kmeisthax committed Jan 5, 2019
1 parent 8a012f6 commit 92f4af2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/rapidtar/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ impl<W:Write> Write for BlockingWriter<W> {
if self.block.len() >= self.blocking_factor {
match self.inner.write_all(&self.block) {
Ok(()) => {
self.block.truncate(0);
//This is actually safe, because this always acts to shrink
//the array, failing to drop values properly is safe (though
//bad practice), and u8 doesn't implement Drop anyway.
unsafe { self.block.set_len(0); }
Ok(write_size)
},
Err(x) => Err(x)
Expand Down

0 comments on commit 92f4af2

Please sign in to comment.