Refactor: reserve space before adding extra data

This commit is contained in:
Chris Hennick 2023-05-14 09:26:33 -07:00
parent 56f9ee9ab0
commit 170e5c6f58
No known key found for this signature in database
GPG key ID: 25653935CC8B6C74

View file

@ -260,6 +260,7 @@ impl FileOptions {
Rc::get_mut(field).unwrap()
}
};
vec.reserve_exact(data.len() + 4);
vec.write_u16::<LittleEndian>(header_id)?;
vec.write_u16::<LittleEndian>(data.len() as u16)?;
vec.write_all(data)?;