diff options
author | George Marques <george@gmarqu.es> | 2020-11-18 11:37:08 -0300 |
---|---|---|
committer | George Marques <george@gmarqu.es> | 2020-11-21 13:30:17 -0300 |
commit | 5518e2a68e36fe8a9dcf1531228a7b3cc4411263 (patch) | |
tree | d0790c288e54056f5a480d43fe88819535c1fa39 /modules/gdscript/gdscript_byte_codegen.h | |
parent | e0dca3c6b6f0a4dc0126c45873ff4c8c30e2d8a0 (diff) | |
download | redot-engine-5518e2a68e36fe8a9dcf1531228a7b3cc4411263.tar.gz |
GDScript: Add faster instruction for validated constructor
Only for built-in types.
Diffstat (limited to 'modules/gdscript/gdscript_byte_codegen.h')
-rw-r--r-- | modules/gdscript/gdscript_byte_codegen.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_byte_codegen.h b/modules/gdscript/gdscript_byte_codegen.h index cced0ecabe..a546920fb2 100644 --- a/modules/gdscript/gdscript_byte_codegen.h +++ b/modules/gdscript/gdscript_byte_codegen.h @@ -69,6 +69,7 @@ class GDScriptByteCodeGenerator : public GDScriptCodeGenerator { Map<Variant::ValidatedIndexedSetter, int> indexed_setters_map; Map<Variant::ValidatedIndexedGetter, int> indexed_getters_map; Map<Variant::ValidatedBuiltInMethod, int> builtin_method_map; + Map<Variant::ValidatedConstructor, int> constructors_map; Map<MethodBind *, int> method_bind_map; List<int> if_jmp_addrs; // List since this can be nested. @@ -211,6 +212,15 @@ class GDScriptByteCodeGenerator : public GDScriptCodeGenerator { return pos; } + int get_constructor_pos(const Variant::ValidatedConstructor p_constructor) { + if (constructors_map.has(p_constructor)) { + return constructors_map[p_constructor]; + } + int pos = constructors_map.size(); + constructors_map[p_constructor] = pos; + return pos; + } + int get_method_bind_pos(MethodBind *p_method) { if (method_bind_map.has(p_method)) { return method_bind_map[p_method]; @@ -312,6 +322,10 @@ class GDScriptByteCodeGenerator : public GDScriptCodeGenerator { opcodes.push_back(get_builtin_method_pos(p_method)); } + void append(const Variant::ValidatedConstructor p_constructor) { + opcodes.push_back(get_constructor_pos(p_constructor)); + } + void append(MethodBind *p_method) { opcodes.push_back(get_method_bind_pos(p_method)); } |