Skip to content

Commit

Permalink
making the implicit copy explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
AsherGlick committed May 19, 2024
1 parent a4a2dc3 commit 79e0586
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions xml_converter/src/packaging_xml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,13 @@ void parse_marker_categories(
}
}

////////////////////////////////////////////////////////////////////////////////
// get_category
//
// Gets the category that this node references as its "type" so that the
// defaults of that category can be used when creating the new node.
////////////////////////////////////////////////////////////////////////////////
Category* get_category(rapidxml::xml_node<>* node, map<string, Category>* marker_categories, vector<XMLError*>* errors) {
// TODO: This is a slow linear search, replace with something faster.
// maybe use data from already parsed node instead of searching for
// the attribute.
rapidxml::xml_attribute<>* attribute = find_attribute(node, "type");

if (attribute == 0) {
Expand Down Expand Up @@ -133,10 +136,12 @@ vector<Parseable*> parse_pois(rapidxml::xml_node<>* root_node, map<string, Categ
if (get_node_name(node) == "POI") {
Category* default_category = get_category(node, marker_categories, errors);

Icon* icon = new Icon();

Icon* icon;
if (default_category != nullptr) {
*icon = default_category->default_icon;
icon = new Icon(default_category->default_icon);
}
else {
icon = new Icon();
}

icon->init_from_xml(node, errors, state);
Expand All @@ -145,10 +150,12 @@ vector<Parseable*> parse_pois(rapidxml::xml_node<>* root_node, map<string, Categ
else if (get_node_name(node) == "Trail") {
Category* default_category = get_category(node, marker_categories, errors);

Trail* trail = new Trail();

Trail* trail;
if (default_category != nullptr) {
*trail = default_category->default_trail;
trail = new Trail(default_category->default_trail);
}
else {
trail = new Trail();
}

trail->init_from_xml(node, errors, state);
Expand Down

0 comments on commit 79e0586

Please sign in to comment.