rust: in zstd decompression, avoid a useless vec initialization
authorArseniy Alekseyev <aalekseyev@janestreet.com>
Thu, 18 May 2023 17:25:18 +0100
changeset 50541 d1cab48354bc
parent 50540 74d8a1b03960
child 50542 39ed7b2953bb
rust: in zstd decompression, avoid a useless vec initialization
rust/hg-core/src/revlog/mod.rs
--- a/rust/hg-core/src/revlog/mod.rs	Thu May 18 17:18:54 2023 +0100
+++ b/rust/hg-core/src/revlog/mod.rs	Thu May 18 17:25:18 2023 +0100
@@ -603,7 +603,7 @@
             Ok(buf)
         } else {
             let cap = self.uncompressed_len.max(0) as usize;
-            let mut buf = vec![0; cap];
+            let mut buf = Vec::with_capacity(cap);
             let len = zstd_decompress_to_buffer(self.bytes, &mut buf)
                 .map_err(|e| corrupted(e.to_string()))?;
             if len != self.uncompressed_len as usize {