Replace most uses of Map by HashMap

* Map is unnecessary and inefficient in almost every case.
* Replaced by the new HashMap.
* Renamed Map to RBMap and Set to RBSet for cases that still make sense
  (order matters) but use is discouraged.

There were very few cases where replacing by HashMap was undesired because
keeping the key order was intended.
I tried to keep those (as RBMap) as much as possible, but might have missed
some. Review appreciated!
This commit is contained in:
reduz 2022-05-13 15:04:37 +02:00 committed by Rémi Verschelde
parent 396def9b66
commit 746dddc067
587 changed files with 3707 additions and 3538 deletions

View file

@ -664,7 +664,7 @@ static Node *_find_node_for_script(Node *p_base, Node *p_current, const Ref<Scri
return nullptr;
}
static void _find_changed_scripts_for_external_editor(Node *p_base, Node *p_current, Set<Ref<Script>> &r_scripts) {
static void _find_changed_scripts_for_external_editor(Node *p_base, Node *p_current, RBSet<Ref<Script>> &r_scripts) {
if (p_current->get_owner() != p_base && p_base != p_current) {
return;
}
@ -686,14 +686,14 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo
ERR_FAIL_COND(!get_tree());
Set<Ref<Script>> scripts;
RBSet<Ref<Script>> scripts;
Node *base = get_tree()->get_edited_scene_root();
if (base) {
_find_changed_scripts_for_external_editor(base, base, scripts);
}
for (Set<Ref<Script>>::Element *E = scripts.front(); E; E = E->next()) {
for (RBSet<Ref<Script>>::Element *E = scripts.front(); E; E = E->next()) {
Ref<Script> script = E->get();
if (p_for_script.is_valid() && p_for_script != script) {
@ -970,7 +970,7 @@ void ScriptTextEditor::_update_connected_methods() {
}
Vector<Node *> nodes = _find_all_node_for_script(base, base, script);
Set<StringName> methods_found;
RBSet<StringName> methods_found;
for (int i = 0; i < nodes.size(); i++) {
List<Connection> connections;
nodes[i]->get_signals_connected_to_this(&connections);
@ -1371,11 +1371,11 @@ void ScriptTextEditor::add_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_hig
void ScriptTextEditor::set_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) {
ERR_FAIL_COND(p_highlighter.is_null());
Map<String, Ref<EditorSyntaxHighlighter>>::Element *el = highlighters.front();
while (el != nullptr) {
int highlighter_index = highlighter_menu->get_item_idx_from_text(el->key());
highlighter_menu->set_item_checked(highlighter_index, el->value() == p_highlighter);
el = el->next();
HashMap<String, Ref<EditorSyntaxHighlighter>>::Iterator el = highlighters.begin();
while (el) {
int highlighter_index = highlighter_menu->get_item_idx_from_text(el->key);
highlighter_menu->set_item_checked(highlighter_index, el->value == p_highlighter);
++el;
}
CodeEdit *te = code_editor->get_text_editor();