Commit 1c707713 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen Committed by Rémi Denis-Courmont

dash: DOMHelper: Avoiding some copies, using operator== instead of compare()

Signed-off-by: Rémi Denis-Courmont's avatarRémi Denis-Courmont <remi@remlab.net>
parent d6576e6a
......@@ -29,7 +29,7 @@
using namespace dash::xml;
std::vector<Node *> DOMHelper::getElementByTagName (Node *root, std::string name, bool selfContain)
std::vector<Node *> DOMHelper::getElementByTagName (Node *root, const std::string& name, bool selfContain)
{
std::vector<Node *> elements;
......@@ -41,20 +41,20 @@ std::vector<Node *> DOMHelper::getElementByTagName (Node *root, std::string
return elements;
}
std::vector<Node *> DOMHelper::getChildElementByTagName (Node *root, std::string name)
std::vector<Node *> DOMHelper::getChildElementByTagName (Node *root, const std::string& name)
{
std::vector<Node *> elements;
for(size_t i = 0; i < root->getSubNodes().size(); i++)
{
if(!root->getSubNodes().at(i)->getName().compare(name))
if( root->getSubNodes().at(i)->getName() == name )
elements.push_back(root->getSubNodes().at(i));
}
return elements;
}
void DOMHelper::getElementsByTagName (Node *root, std::string name, std::vector<Node*> *elements, bool selfContain)
void DOMHelper::getElementsByTagName (Node *root, const std::string& name, std::vector<Node*> *elements, bool selfContain)
{
if(!selfContain && !root->getName().compare(name))
{
......@@ -75,7 +75,7 @@ Node* DOMHelper::getFirstChildElementByName( Node *root, const std::st
{
for(size_t i = 0; i < root->getSubNodes().size(); i++)
{
if( !root->getSubNodes().at( i )->getName().compare( name ) )
if( root->getSubNodes().at( i )->getName() == name )
return root->getSubNodes().at( i );
}
return NULL;
......
......@@ -37,12 +37,12 @@ namespace dash
class DOMHelper
{
public:
static std::vector<Node *> getElementByTagName (Node *root, std::string name, bool selfContain);
static std::vector<Node *> getChildElementByTagName (Node *root, std::string name);
static std::vector<Node *> getElementByTagName (Node *root, const std::string& name, bool selfContain);
static std::vector<Node *> getChildElementByTagName (Node *root, const std::string& name);
static Node* getFirstChildElementByName( Node *root, const std::string& name );
private:
static void getElementsByTagName(Node *root, std::string name, std::vector<Node *> *elements, bool selfContain);
static void getElementsByTagName(Node *root, const std::string& name, std::vector<Node *> *elements, bool selfContain);
};
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment