From 170e5c6f58b9f340a8f4ed5ff677361659fd921d Mon Sep 17 00:00:00 2001 From: Chris Hennick Date: Sun, 14 May 2023 09:26:33 -0700 Subject: [PATCH] Refactor: reserve space before adding extra data --- src/write.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/write.rs b/src/write.rs index ed332e59..7eaa8d27 100644 --- a/src/write.rs +++ b/src/write.rs @@ -260,6 +260,7 @@ impl FileOptions { Rc::get_mut(field).unwrap() } }; + vec.reserve_exact(data.len() + 4); vec.write_u16::(header_id)?; vec.write_u16::(data.len() as u16)?; vec.write_all(data)?;