From 362d822ee45f7840cca4ac169ccca0f3bc706e48 Mon Sep 17 00:00:00 2001 From: Emil Engler Date: Tue, 25 Oct 2022 16:24:42 +0200 Subject: [PATCH] tor-bytes: Avoid redundant allocation See c489e1d9118edd842f80b76a636037524a45ee45 --- crates/tor-bytes/src/reader.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/tor-bytes/src/reader.rs b/crates/tor-bytes/src/reader.rs index 7a16474a9..7e19e2080 100644 --- a/crates/tor-bytes/src/reader.rs +++ b/crates/tor-bytes/src/reader.rs @@ -262,7 +262,7 @@ impl<'a> Reader<'a> { /// /// On failure, consumes nothing. pub fn extract_n(&mut self, n: usize) -> Result> { - let mut result = Vec::new(); + let mut result = Vec::with_capacity(n); let off_orig = self.off; for _ in 0..n { match E::take_from(self) {