diff --git a/implementations/rust/preserves/src/value/iolist.rs b/implementations/rust/preserves/src/value/iolist.rs index 6a7e5da..9061d8e 100644 --- a/implementations/rust/preserves/src/value/iolist.rs +++ b/implementations/rust/preserves/src/value/iolist.rs @@ -11,14 +11,14 @@ pub struct IOList { impl IOList { pub fn new() -> Self { IOList { - chunks: vec![], + chunks: Vec::with_capacity(5), len: 0, } } fn rightmost_chunk(&mut self) -> &mut Vec { if self.chunks.is_empty() { - self.chunks.push(vec![]); + self.chunks.push(Vec::with_capacity(64)) } self.chunks.last_mut().unwrap() } diff --git a/implementations/rust/preserves/src/value/packed/writer.rs b/implementations/rust/preserves/src/value/packed/writer.rs index e71c8e2..7d46659 100644 --- a/implementations/rust/preserves/src/value/packed/writer.rs +++ b/implementations/rust/preserves/src/value/packed/writer.rs @@ -55,7 +55,7 @@ impl PackedWriter { PackedWriter { w: write, buffer: IOList::new(), - items: Vec::new(), + items: Vec::with_capacity(16), streaming: false, } } @@ -117,7 +117,7 @@ impl PackedWriter { } pub fn start_seq(&mut self) -> io::Result<()> { - self.items.push(Vec::new()); + self.items.push(Vec::with_capacity(32)); Ok(()) }