diff options
author | cdemirer <41021322+cdemirer@users.noreply.github.com> | 2022-01-02 05:43:52 +0800 |
---|---|---|
committer | cdemirer <41021322+cdemirer@users.noreply.github.com> | 2022-01-02 05:43:52 +0800 |
commit | 511e699feeaeb5b7ce5882b62d424af614a157cf (patch) | |
tree | 45cb9149bf963122cfc9d8620f58ca69dc54686d /modules | |
parent | 91b97dac03996c4b8791633ea6fa8fdc47852cb6 (diff) |
Fix unexpected Packed Array copying when parameter is typed
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdscript/gdscript_vm.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp index be9e5df2b0..7e087b842f 100644 --- a/modules/gdscript/gdscript_vm.cpp +++ b/modules/gdscript/gdscript_vm.cpp @@ -488,7 +488,12 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a memnew_placement(&stack[i + 3], Variant(*p_args[i])); continue; } - + // If types already match, don't call Variant::construct(). Constructors of some types + // (e.g. packed arrays) do copies, whereas they pass by reference when inside a Variant. + if (argument_types[i].is_type(*p_args[i], false)) { + memnew_placement(&stack[i + 3], Variant(*p_args[i])); + continue; + } if (!argument_types[i].is_type(*p_args[i], true)) { r_err.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; r_err.argument = i; |