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/main/node.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'scene/main/node.cpp') diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 8961b5ba54..0c1a62c667 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1637,7 +1637,7 @@ Node *Node::find_common_parent_with(const Node *p_node) const { return const_cast(p_node); } - Set visited; + RBSet visited; const Node *n = this; @@ -1669,7 +1669,7 @@ NodePath Node::get_path_to(const Node *p_node) const { return NodePath("."); } - Set visited; + RBSet visited; const Node *n = this; @@ -1763,15 +1763,15 @@ void Node::add_to_group(const StringName &p_identifier, bool p_persistent) { void Node::remove_from_group(const StringName &p_identifier) { ERR_FAIL_COND(!data.grouped.has(p_identifier)); - Map::Element *E = data.grouped.find(p_identifier); + HashMap::Iterator E = data.grouped.find(p_identifier); ERR_FAIL_COND(!E); if (data.tree) { - data.tree->remove_from_group(E->key(), this); + data.tree->remove_from_group(E->key, this); } - data.grouped.erase(E); + data.grouped.remove(E); } Array Node::_get_groups() const { @@ -2042,7 +2042,7 @@ StringName Node::get_property_store_alias(const StringName &p_property) const { } #endif -void Node::get_storable_properties(Set &r_storable_properties) const { +void Node::get_storable_properties(RBSet &r_storable_properties) const { List pi; get_property_list(&pi); for (List::Element *E = pi.front(); E; E = E->next()) { @@ -2088,7 +2088,7 @@ bool Node::get_scene_instance_load_placeholder() const { return data.use_placeholder; } -Node *Node::_duplicate(int p_flags, Map *r_duplimap) const { +Node *Node::_duplicate(int p_flags, HashMap *r_duplimap) const { Node *node = nullptr; bool instantiated = false; @@ -2280,11 +2280,11 @@ Node *Node::duplicate(int p_flags) const { } #ifdef TOOLS_ENABLED -Node *Node::duplicate_from_editor(Map &r_duplimap) const { - return duplicate_from_editor(r_duplimap, Map, Ref>()); +Node *Node::duplicate_from_editor(HashMap &r_duplimap) const { + return duplicate_from_editor(r_duplimap, HashMap, Ref>()); } -Node *Node::duplicate_from_editor(Map &r_duplimap, const Map, Ref> &p_resource_remap) const { +Node *Node::duplicate_from_editor(HashMap &r_duplimap, const HashMap, Ref> &p_resource_remap) const { Node *dupe = _duplicate(DUPLICATE_SIGNALS | DUPLICATE_GROUPS | DUPLICATE_SCRIPTS | DUPLICATE_USE_INSTANCING | DUPLICATE_FROM_EDITOR, &r_duplimap); // This is used by SceneTreeDock's paste functionality. When pasting to foreign scene, resources are duplicated. @@ -2300,7 +2300,7 @@ Node *Node::duplicate_from_editor(Map &r_duplimap, const M return dupe; } -void Node::remap_node_resources(Node *p_node, const Map, Ref> &p_resource_remap) const { +void Node::remap_node_resources(Node *p_node, const HashMap, Ref> &p_resource_remap) const { List props; p_node->get_property_list(&props); @@ -2326,7 +2326,7 @@ void Node::remap_node_resources(Node *p_node, const Map, Ref p_resource, const Map, Ref> &p_resource_remap) const { +void Node::remap_nested_resources(Ref p_resource, const HashMap, Ref> &p_resource_remap) const { List props; p_resource->get_property_list(&props); -- cgit v1.2.3