when rewriting the buffer, reserve enougth space
This commit is contained in:
parent
7fca8b0ec5
commit
716c907dc2
@ -459,6 +459,8 @@ impl BasicEncoder {
|
|||||||
fn insert_list_len_at_pos(&mut self, len: usize, pos: usize) -> () {
|
fn insert_list_len_at_pos(&mut self, len: usize, pos: usize) -> () {
|
||||||
// new bytes
|
// new bytes
|
||||||
let mut res: Vec<u8> = vec![];
|
let mut res: Vec<u8> = vec![];
|
||||||
|
// reserve a space equal at least current space + space for length
|
||||||
|
res.reserve(self.bytes.len() + 1);
|
||||||
{
|
{
|
||||||
let (before_slice, after_slice) = self.bytes.split_at(pos);
|
let (before_slice, after_slice) = self.bytes.split_at(pos);
|
||||||
res.extend(before_slice);
|
res.extend(before_slice);
|
||||||
|
Loading…
Reference in New Issue
Block a user