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 operator for known types
It now uses the direct operator function pointer, which increases performance in evaluation.
This commit is contained in:
@@ -188,6 +188,7 @@ String GDScriptFunction::_get_call_error(const Callable::CallError &p_err, const
|
||||
#define OPCODES_TABLE \
|
||||
static const void *switch_table_ops[] = { \
|
||||
&&OPCODE_OPERATOR, \
|
||||
&&OPCODE_OPERATOR_VALIDATED, \
|
||||
&&OPCODE_EXTENDS_TEST, \
|
||||
&&OPCODE_IS_BUILTIN, \
|
||||
&&OPCODE_SET, \
|
||||
@@ -468,6 +469,23 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
||||
}
|
||||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_OPERATOR_VALIDATED) {
|
||||
CHECK_SPACE(5);
|
||||
|
||||
int operator_idx = _code_ptr[ip + 4];
|
||||
GD_ERR_BREAK(operator_idx < 0 || operator_idx >= _operator_funcs_count);
|
||||
Variant::ValidatedOperatorEvaluator operator_func = _operator_funcs_ptr[operator_idx];
|
||||
|
||||
GET_INSTRUCTION_ARG(a, 0);
|
||||
GET_INSTRUCTION_ARG(b, 1);
|
||||
GET_INSTRUCTION_ARG(dst, 2);
|
||||
|
||||
operator_func(a, b, dst);
|
||||
|
||||
ip += 5;
|
||||
}
|
||||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_EXTENDS_TEST) {
|
||||
CHECK_SPACE(4);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user