mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 07:53:26 +00:00
Avoid repeated _copy_on_write() calls in Array::resize()
Updated Array::resize() to call ptrw() once before looping to initialize typed array elements, instead of accessing each through .write[].
This commit is contained in:
parent
2b832e9974
commit
4c3f2be16d
1 changed files with 2 additions and 1 deletions
|
@ -305,8 +305,9 @@ Error Array::resize(int p_new_size) {
|
|||
int old_size = _p->array.size();
|
||||
Error err = _p->array.resize_initialized(p_new_size);
|
||||
if (!err && variant_type != Variant::NIL && variant_type != Variant::OBJECT) {
|
||||
Variant *write = _p->array.ptrw();
|
||||
for (int i = old_size; i < p_new_size; i++) {
|
||||
VariantInternal::initialize(&_p->array.write[i], variant_type);
|
||||
VariantInternal::initialize(&write[i], variant_type);
|
||||
}
|
||||
}
|
||||
return err;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue