mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 18:03:37 +08:00
io: use Vec::with_capacity
This commit is contained in:
parent
c6e905a1b9
commit
b8c5627eb1
|
@ -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<u8> {
|
||||
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() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user