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:
George Marques 2020-11-13 16:47:45 -03:00
parent c707d6fe71
commit 1ad5c926dc
No known key found for this signature in database
GPG key ID: 046BD46A3201E43D
5 changed files with 77 additions and 3 deletions

View file

@ -159,6 +159,7 @@ class GDScriptFunction {
public:
enum Opcode {
OPCODE_OPERATOR,
OPCODE_OPERATOR_VALIDATED,
OPCODE_EXTENDS_TEST,
OPCODE_IS_BUILTIN,
OPCODE_SET,
@ -241,6 +242,8 @@ private:
int _global_names_count = 0;
const int *_default_arg_ptr = nullptr;
int _default_arg_count = 0;
int _operator_funcs_count = 0;
const Variant::ValidatedOperatorEvaluator *_operator_funcs_ptr = nullptr;
const int *_code_ptr = nullptr;
int _code_size = 0;
int _argument_count = 0;
@ -256,6 +259,7 @@ private:
Vector<Variant> constants;
Vector<StringName> global_names;
Vector<int> default_arguments;
Vector<Variant::ValidatedOperatorEvaluator> operator_funcs;
Vector<int> code;
Vector<GDScriptDataType> argument_types;
GDScriptDataType return_type;