From 18b9cb5df42c79844d486c144991c32c5e516d3b Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Wed, 13 Jul 2022 14:01:20 +0200 Subject: [PATCH] Win from avoiding some allocation --- implementations/rust/preserves/src/value/iolist.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations/rust/preserves/src/value/iolist.rs b/implementations/rust/preserves/src/value/iolist.rs index 9061d8e..2f31226 100644 --- a/implementations/rust/preserves/src/value/iolist.rs +++ b/implementations/rust/preserves/src/value/iolist.rs @@ -36,7 +36,7 @@ impl IOList { pub fn write_all(&mut self, cow: Cow<'_, [u8]>) { self.len += cow.len(); match cow { - Cow::Borrowed(bs) => self.chunks.push(bs.to_owned()), + Cow::Borrowed(bs) => self.rightmost_chunk().extend_from_slice(bs), Cow::Owned(bs) => self.chunks.push(bs), } }