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

Smoke test: In collections, log an error if reserve() is called with a number smaller than the current size. Don't log an error if it is called with a number smaller than the current capacity.

This commit is contained in:
Lukas Tenbrink
2025-04-11 14:49:49 +02:00
parent 1696ab0cb6
commit 7c37188ca1
7 changed files with 16 additions and 13 deletions

View File

@@ -117,7 +117,8 @@ StringBuffer<SHORT_BUFFER_SIZE> &StringBuffer<SHORT_BUFFER_SIZE>::append(const c
template <int SHORT_BUFFER_SIZE>
StringBuffer<SHORT_BUFFER_SIZE> &StringBuffer<SHORT_BUFFER_SIZE>::reserve(int p_size) {
if (p_size < SHORT_BUFFER_SIZE || p_size < buffer.size() || !p_size) {
ERR_FAIL_COND_V_MSG(p_size < length(), *this, "reserve() called with a capacity smaller than the current size. This is likely a mistake.");
if (p_size <= SHORT_BUFFER_SIZE || p_size <= buffer.size()) {
return *this;
}