You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
GDScript: Add faster instruction for validated constructor
Only for built-in types.
This commit is contained in:
@@ -214,6 +214,7 @@ String GDScriptFunction::_get_call_error(const Callable::CallError &p_err, const
|
||||
&&OPCODE_CAST_TO_NATIVE, \
|
||||
&&OPCODE_CAST_TO_SCRIPT, \
|
||||
&&OPCODE_CONSTRUCT, \
|
||||
&&OPCODE_CONSTRUCT_VALIDATED, \
|
||||
&&OPCODE_CONSTRUCT_ARRAY, \
|
||||
&&OPCODE_CONSTRUCT_DICTIONARY, \
|
||||
&&OPCODE_CALL, \
|
||||
@@ -1276,6 +1277,27 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
||||
}
|
||||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_CONSTRUCT_VALIDATED) {
|
||||
CHECK_SPACE(2 + instr_arg_count);
|
||||
|
||||
ip += instr_arg_count;
|
||||
|
||||
int argc = _code_ptr[ip + 1];
|
||||
|
||||
int constructor_idx = _code_ptr[ip + 2];
|
||||
GD_ERR_BREAK(constructor_idx < 0 || constructor_idx >= _constructors_count);
|
||||
Variant::ValidatedConstructor constructor = _constructors_ptr[constructor_idx];
|
||||
|
||||
Variant **argptrs = instruction_args;
|
||||
|
||||
GET_INSTRUCTION_ARG(dst, argc);
|
||||
|
||||
constructor(*dst, (const Variant **)argptrs);
|
||||
|
||||
ip += 3;
|
||||
}
|
||||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_CONSTRUCT_ARRAY) {
|
||||
CHECK_SPACE(1 + instr_arg_count);
|
||||
ip += instr_arg_count;
|
||||
|
||||
Reference in New Issue
Block a user