Refactor: reserve space before adding extra data
This commit is contained in:
parent
56f9ee9ab0
commit
170e5c6f58
1 changed files with 1 additions and 0 deletions
|
@ -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)?;
|
||||
|
|
Loading…
Add table
Reference in a new issue