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:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user