Preallocate tree arrays when popping from the stack

This commit is contained in:
Max Brunsfeld 2018-04-09 18:09:54 -07:00
parent ff70f8d881
commit b0b8279c14
4 changed files with 38 additions and 27 deletions

View file

@ -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]);
}