GDScript: Optimize operators by assuming the types

This assumes that operators are called usually with the same type of
operands as the first time. So it stores the types of the first run and
if matched it uses an optimized path by calling the validated operator
function directly. Otherwise it uses the regular untyped evaluator.

With this change, if operators do use the same type they run quite
faster. OTOH, if the types mismatch it takes longer to run than they
would with the previous code.
This commit is contained in:
George Marques 2023-07-28 13:08:21 -03:00
parent 202e4b2c1e
commit c1bca65d09
No known key found for this signature in database
GPG key ID: 046BD46A3201E43D
4 changed files with 78 additions and 21 deletions

View file

@ -473,7 +473,7 @@ private:
MethodBind **_methods_ptr = nullptr;
int _lambdas_count = 0;
GDScriptFunction **_lambdas_ptr = nullptr;
const int *_code_ptr = nullptr;
int *_code_ptr = nullptr;
int _code_size = 0;
int _argument_count = 0;
int _stack_size = 0;