mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +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:
parent
1f7630f1bf
commit
1bf821c1e1
11 changed files with 441 additions and 201 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ public:
|
|||
_FORCE_INLINE_ void append(const Variant &p_value) { push_back(p_value); } //for python compatibility
|
||||
void append_array(const Array &p_array);
|
||||
Error resize(int p_new_size);
|
||||
Error reserve(int p_new_size);
|
||||
|
||||
Error insert(int p_pos, const Variant &p_value);
|
||||
void remove_at(int p_pos);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue