Skip to content

Commit 92f4af2

Browse files
committed
Fix the actual god damned bottleneck, because calling .truncate() actually tries to drop every byte in the array. Telling the vector to forget it's contents is a better approach
1 parent 8a012f6 commit 92f4af2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/rapidtar/blocking.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ impl<W:Write> Write for BlockingWriter<W> {
7575
if self.block.len() >= self.blocking_factor {
7676
match self.inner.write_all(&self.block) {
7777
Ok(()) => {
78-
self.block.truncate(0);
78+
//This is actually safe, because this always acts to shrink
79+
//the array, failing to drop values properly is safe (though
80+
//bad practice), and u8 doesn't implement Drop anyway.
81+
unsafe { self.block.set_len(0); }
7982
Ok(write_size)
8083
},
8184
Err(x) => Err(x)

0 commit comments

Comments
 (0)