src/backup/data_blob.rs: improve decompress speed

This commit is contained in:
Dietmar Maurer 2020-09-24 08:52:35 +02:00
parent 298c6aaef6
commit 09a1da25ed

View File

@ -198,7 +198,10 @@ impl DataBlob {
Ok(data) Ok(data)
} else if magic == &COMPRESSED_BLOB_MAGIC_1_0 { } else if magic == &COMPRESSED_BLOB_MAGIC_1_0 {
let data_start = std::mem::size_of::<DataBlobHeader>(); let data_start = std::mem::size_of::<DataBlobHeader>();
let data = zstd::block::decompress(&self.raw_data[data_start..], MAX_BLOB_SIZE)?; let mut reader = &self.raw_data[data_start..];
let data = zstd::stream::decode_all(&mut reader)?;
// zstd::block::decompress is abou 10% slower
// let data = zstd::block::decompress(&self.raw_data[data_start..], MAX_BLOB_SIZE)?;
if let Some(digest) = digest { if let Some(digest) = digest {
Self::verify_digest(&data, None, digest)?; Self::verify_digest(&data, None, digest)?;
} }