Add minor performance bump to shredding (#5956)

This commit is contained in:
Sagar Dhawan
2019-09-18 12:35:52 -07:00
committed by GitHub
parent 8b99e6dfbe
commit b757294864
2 changed files with 36 additions and 3 deletions

View File

@ -648,9 +648,8 @@ impl Shredder {
/// Finalize a data shred. Update the shred index for the next shred
fn finalize_data_shred(&mut self) {
let mut data = vec![0; PACKET_DATA_SIZE];
let mut wr = io::Cursor::new(&mut data[..]);
bincode::serialize_into(&mut wr, &self.active_shred).expect("Failed to serialize shred");
let mut data = Vec::with_capacity(PACKET_DATA_SIZE);
bincode::serialize_into(&mut data, &self.active_shred).expect("Failed to serialize shred");
self.active_offset = 0;
self.index += 1;