Preallocate tree arrays when popping from the stack
This commit is contained in:
parent
ff70f8d881
commit
b0b8279c14
4 changed files with 38 additions and 27 deletions
|
|
@ -82,7 +82,7 @@ TreeArray ts_tree_array_remove_last_n(TreeArray *self, uint32_t remove_count) {
|
|||
}
|
||||
}
|
||||
|
||||
array_grow(&result, self->size - split_index);
|
||||
array_reserve(&result, self->size - split_index);
|
||||
for (uint32_t i = split_index; i < self->size; i++) {
|
||||
array_push(&result, self->contents[i]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue