1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Store current capacity in CowData buffers, and rewrite most of it.

Add `reserve` to `CowData`, `Vector` and `Array`.

# Conflicts:
#	core/os/memory.h
#	core/templates/cowdata.h
This commit is contained in:
Lukas Tenbrink
2025-05-01 23:31:54 +02:00
parent 1f7630f1bf
commit 1bf821c1e1
11 changed files with 441 additions and 201 deletions

View File

@@ -313,6 +313,11 @@ Error Array::resize(int p_new_size) {
return err;
}
Error Array::reserve(int p_new_size) {
ERR_FAIL_COND_V_MSG(_p->read_only, ERR_LOCKED, "Array is in read-only state.");
return _p->array.reserve(p_new_size);
}
Error Array::insert(int p_pos, const Variant &p_value) {
ERR_FAIL_COND_V_MSG(_p->read_only, ERR_LOCKED, "Array is in read-only state.");
Variant value = p_value;