changeset 50507:d1cab48354bc

rust: in zstd decompression, avoid a useless vec initialization
author Arseniy Alekseyev <aalekseyev@janestreet.com>
date Thu, 18 May 2023 17:25:18 +0100
parents 74d8a1b03960
children 39ed7b2953bb
files rust/hg-core/src/revlog/mod.rs
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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 {