tor-bytes: Avoid redundant allocation

See c489e1d911
This commit is contained in:
Emil Engler 2022-10-25 16:24:42 +02:00
parent 49ffb1cf4b
commit 362d822ee4
No known key found for this signature in database
GPG Key ID: 2F6D4145C55FC7C7
1 changed files with 1 additions and 1 deletions

View File

@ -262,7 +262,7 @@ impl<'a> Reader<'a> {
///
/// On failure, consumes nothing.
pub fn extract_n<E: Readable>(&mut self, n: usize) -> Result<Vec<E>> {
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) {