diff options
author | Mikael Hermansson <mikael@hermansson.io> | 2024-07-18 12:30:43 +0200 |
---|---|---|
committer | Mikael Hermansson <mikael@hermansson.io> | 2024-07-18 12:30:45 +0200 |
commit | 6852f9497cf14dec69682929ccf574c2e5e83bfd (patch) | |
tree | 464ae27cb14bac5e2329cba6937a3d1914336fde /modules/gdscript/gdscript.cpp | |
parent | 6b5825a0cb13494d2d26a72f59a81399a7209461 (diff) | |
download | redot-engine-6852f9497cf14dec69682929ccf574c2e5e83bfd.tar.gz |
Speed up `GDScriptLanguage::finish`
Diffstat (limited to 'modules/gdscript/gdscript.cpp')
-rw-r--r-- | modules/gdscript/gdscript.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 73b1e44db3..eaf2565e69 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -1537,10 +1537,14 @@ void GDScript::clear(ClearData *p_clear_data) { } } - RBSet<GDScript *> must_clear_dependencies = get_must_clear_dependencies(); - for (GDScript *E : must_clear_dependencies) { - clear_data->scripts.insert(E); - E->clear(clear_data); + // If we're in the process of shutting things down then every single script will be cleared + // anyway, so we can safely skip this very costly operation. + if (!GDScriptLanguage::singleton->finishing) { + RBSet<GDScript *> must_clear_dependencies = get_must_clear_dependencies(); + for (GDScript *E : must_clear_dependencies) { + clear_data->scripts.insert(E); + E->clear(clear_data); + } } for (const KeyValue<StringName, GDScriptFunction *> &E : member_functions) { @@ -2246,6 +2250,11 @@ String GDScriptLanguage::get_extension() const { } void GDScriptLanguage::finish() { + if (finishing) { + return; + } + finishing = true; + _call_stack.free(); // Clear the cache before parsing the script_list @@ -2281,6 +2290,8 @@ void GDScriptLanguage::finish() { } script_list.clear(); function_list.clear(); + + finishing = false; } void GDScriptLanguage::profiling_start() { |