mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 07:53:26 +00:00
Merge pull request #111084 from Ivorforce/cowdata-reserve-verbose
Make `CowData::reserve` warn message when new capacity < size verbose, like other `reserve` methods
This commit is contained in:
commit
55ac91b887
1 changed files with 5 additions and 2 deletions
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "core/error/error_macros.h"
|
||||
#include "core/os/memory.h"
|
||||
#include "core/string/print_string.h"
|
||||
#include "core/templates/safe_refcount.h"
|
||||
#include "core/templates/span.h"
|
||||
|
||||
|
@ -373,9 +374,11 @@ Error CowData<T>::push_back(const T &p_val) {
|
|||
|
||||
template <typename T>
|
||||
Error CowData<T>::reserve(USize p_min_capacity) {
|
||||
ERR_FAIL_COND_V_MSG(p_min_capacity < (USize)size(), ERR_INVALID_PARAMETER, "reserve() called with a capacity smaller than the current size. This is likely a mistake.");
|
||||
|
||||
if (p_min_capacity <= capacity()) {
|
||||
if (p_min_capacity < (USize)size()) {
|
||||
WARN_VERBOSE("reserve() called with a capacity smaller than the current size. This is likely a mistake.");
|
||||
}
|
||||
|
||||
// No need to reserve more, we already have (at least) the right size.
|
||||
return OK;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue