From b8c5627eb174e4a5647a0f5490b075949aa9d8f0 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 13 Oct 2023 10:59:12 +0200 Subject: [PATCH] io: use Vec::with_capacity --- fish-rust/src/io.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fish-rust/src/io.rs b/fish-rust/src/io.rs index 6c37cba16..175e85b93 100644 --- a/fish-rust/src/io.rs +++ b/fish-rust/src/io.rs @@ -82,7 +82,7 @@ impl SeparatedBuffer { } /// \return the contents size. - pub fn size(&self) -> usize { + pub fn len(&self) -> usize { self.contents_size } @@ -94,8 +94,7 @@ impl SeparatedBuffer { /// Serialize the contents to a single string, where explicitly separated elements have a /// newline appended. pub fn newline_serialized(&self) -> Vec { - let mut result = vec![]; - result.reserve(self.size()); + let mut result = Vec::with_capacity(self.len()); for elem in &self.elements { result.extend_from_slice(&elem.contents); if elem.is_explicitly_separated() {