Merge pull request #110709 from DeeJayLSP/dict-reserve

Add `reserve()` to `Dictionary`, apply to constructors on GDScript VM
This commit is contained in:
Thaddeus Crews 2025-10-20 18:09:58 -05:00
commit f50d7fa1e8
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
3 changed files with 10 additions and 2 deletions

View file

@ -1829,7 +1829,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
int argc = _code_ptr[ip + 1];
Dictionary dict;
dict.reserve(argc);
for (int i = 0; i < argc; i++) {
GET_INSTRUCTION_ARG(k, i * 2 + 0);
GET_INSTRUCTION_ARG(v, i * 2 + 1);
@ -1867,7 +1867,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
Dictionary dict;
dict.set_typed(key_builtin_type, key_native_type, *key_script_type, value_builtin_type, value_native_type, *value_script_type);
dict.reserve(argc);
for (int i = 0; i < argc; i++) {
GET_INSTRUCTION_ARG(k, i * 2 + 0);
GET_INSTRUCTION_ARG(v, i * 2 + 1);