refactoring: change string to ref-to-string in own tree 37/201037/2
authorAdrian Szyndela <adrian.s@samsung.com>
Thu, 7 Mar 2019 10:34:54 +0000 (11:34 +0100)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Thu, 7 Mar 2019 14:22:41 +0000 (15:22 +0100)
This changes std::string in construction of TreeNode to reference-to-string
to avoid additional copy of the string.

Change-Id: I49ac9d8e83f8691c022c9113d427bc60c7463902

src/internal/own_tree.cpp
src/internal/own_tree.hpp

index ceebd3d..1eb58f1 100644 (file)
@@ -42,7 +42,7 @@ void OwnershipTree::addItem(const ItemOwn &item) {
        __root->add(tokens, item.getDecision(), item.isPrefix());
 }
 
-TreeNode::TreeNode(std::string token)
+TreeNode::TreeNode(const std::string &token)
 :__token(token), __own_prefix_decision_item(Decision::ANY), __own_decision_item(Decision::ANY)
 {}
 
index 8823706..c96a861 100644 (file)
@@ -33,7 +33,7 @@ namespace ldp_xml_parser
 
        class TreeNode{
        public:
-               TreeNode(std::string token);
+               explicit TreeNode(const std::string &token);
                void add(std::deque<std::string>& tokens, const DecisionItem& decision, const bool is_prefix);
                void setDecisionItem(const DecisionItem& decision, const bool is_prefix);
                const std::string &getToken() const;