From 746dddc0673d7261f19b1e056e90e6e3a49ef33a Mon Sep 17 00:00:00 2001 From: reduz Date: Fri, 13 May 2022 15:04:37 +0200 Subject: 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! --- scene/debugger/scene_debugger.cpp | 98 +++++++++++++++++++-------------------- scene/debugger/scene_debugger.h | 8 ++-- 2 files changed, 53 insertions(+), 53 deletions(-) (limited to 'scene/debugger') diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp index 17b573b776..b792b11dbc 100644 --- a/scene/debugger/scene_debugger.cpp +++ b/scene/debugger/scene_debugger.cpp @@ -68,7 +68,7 @@ bool SceneDebugger::RPCProfilerFrame::deserialize(const Array &p_arr) { } class SceneDebugger::RPCProfiler : public EngineProfiler { - Map rpc_node_data; + HashMap rpc_node_data; uint64_t last_profile_time = 0; void init_node(const ObjectID p_node) { @@ -345,22 +345,22 @@ void SceneDebugger::remove_from_cache(const String &p_filename, Node *p_node) { return; } - Map> &edit_cache = debugger->live_scene_edit_cache; - Map>::Element *E = edit_cache.find(p_filename); + HashMap> &edit_cache = debugger->live_scene_edit_cache; + HashMap>::Iterator E = edit_cache.find(p_filename); if (E) { - E->get().erase(p_node); - if (E->get().size() == 0) { - edit_cache.erase(E); + E->value.erase(p_node); + if (E->value.size() == 0) { + edit_cache.remove(E); } } - Map> &remove_list = debugger->live_edit_remove_list; - Map>::Element *F = remove_list.find(p_node); + HashMap> &remove_list = debugger->live_edit_remove_list; + HashMap>::Iterator F = remove_list.find(p_node); if (F) { - for (const KeyValue &G : F->get()) { + for (const KeyValue &G : F->value) { memdelete(G.value); } - remove_list.erase(F); + remove_list.remove(F); } } @@ -408,47 +408,47 @@ SceneDebuggerObject::SceneDebuggerObject(ObjectID p_id) { } void SceneDebuggerObject::_parse_script_properties(Script *p_script, ScriptInstance *p_instance) { - typedef Map> ScriptMemberMap; - typedef Map> ScriptConstantsMap; + typedef HashMap> ScriptMemberMap; + typedef HashMap> ScriptConstantsMap; ScriptMemberMap members; if (p_instance) { - members[p_script] = Set(); + members[p_script] = RBSet(); p_script->get_members(&(members[p_script])); } ScriptConstantsMap constants; - constants[p_script] = Map(); + constants[p_script] = HashMap(); p_script->get_constants(&(constants[p_script])); Ref