From d5cbb5ce1d679a79deace25ea6c9f19d285d8f08 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 21 Feb 2023 13:24:53 +0100 Subject: [PATCH] Ported: Improve GDScript Editor and Improve latency Improvements: - GDScript Highlighter is faster by 25% as keys are smaller (hashes instead of strings) - Removes message queue from _apply_settings_change to allow resize to work correctly - Some performance fixes are pending still Note: this resolves the code editor behaving badly when resizing in debug builds - RevoluPowered, akien-mga https://github.com/godotengine/godot/commit/1881b3adc555f84cce8d9a0b0231bb2aa1b10d2d --- modules/gdscript/editor/gdscript_highlighter.cpp | 8 ++++---- modules/gdscript/editor/gdscript_highlighter.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index d70d90c80..fecd9de2d 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -468,7 +468,7 @@ void GDScriptSyntaxHighlighter::_update_cache() { List global_classes; ScriptServer::get_global_class_list(&global_classes); for (List::Element *E = global_classes.front(); E; E = E->next()) { - keywords[String(E->get())] = usertype_color; + keywords[E->get()] = usertype_color; } /* Autoloads. */ @@ -503,7 +503,7 @@ void GDScriptSyntaxHighlighter::_update_cache() { List core_types; gdscript->get_core_type_words(&core_types); for (List::Element *E = core_types.front(); E; E = E->next()) { - keywords[E->get()] = basetype_color; + keywords[StringName(E->get())] = basetype_color; } /* Reserved words. */ @@ -513,9 +513,9 @@ void GDScriptSyntaxHighlighter::_update_cache() { gdscript->get_reserved_words(&keyword_list); for (List::Element *E = keyword_list.front(); E; E = E->next()) { if (gdscript->is_control_flow_keyword(E->get())) { - keywords[E->get()] = control_flow_keyword_color; + keywords[StringName(E->get())] = control_flow_keyword_color; } else { - keywords[E->get()] = keyword_color; + keywords[StringName(E->get())] = keyword_color; } } diff --git a/modules/gdscript/editor/gdscript_highlighter.h b/modules/gdscript/editor/gdscript_highlighter.h index a6cfae19a..0adb5356a 100644 --- a/modules/gdscript/editor/gdscript_highlighter.h +++ b/modules/gdscript/editor/gdscript_highlighter.h @@ -46,8 +46,8 @@ private: Vector color_regions; RBMap color_region_cache; - Dictionary keywords; - Dictionary member_keywords; + HashMap keywords; + HashMap member_keywords; enum Type { NONE,