1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-10 13:00:37 +00:00

Add resize_initialized and resize_uninitialized to Vector. These functions serve as replacements for resize, to make sure the caller understands whether elements need to be initialized 'by hand' after the call.

This commit is contained in:
Lukas Tenbrink
2025-05-23 00:20:22 +02:00
parent 6c9765d87e
commit 4cb8a0c77e
24 changed files with 62 additions and 44 deletions

View File

@@ -304,7 +304,7 @@ Error Array::resize(int p_new_size) {
ERR_FAIL_COND_V_MSG(_p->read_only, ERR_LOCKED, "Array is in read-only state.");
Variant::Type &variant_type = _p->typed.type;
int old_size = _p->array.size();
Error err = _p->array.resize_zeroed(p_new_size);
Error err = _p->array.resize_initialized(p_new_size);
if (!err && variant_type != Variant::NIL && variant_type != Variant::OBJECT) {
for (int i = old_size; i < p_new_size; i++) {
VariantInternal::initialize(&_p->array.write[i], variant_type);