[vlc-commits] dash: DOMHelper: Avoiding some copies, using operator== instead of compare( )

Hugo Beauzée-Luyssen git at videolan.org
Thu Nov 24 18:14:57 CET 2011


vlc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Thu Nov 24 17:35:14 2011 +0100| [1c707713b742f75bb3d799ce3909d81707d363e4] | committer: Rémi Denis-Courmont

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

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1c707713b742f75bb3d799ce3909d81707d363e4
---

 modules/stream_filter/dash/xml/DOMHelper.cpp |   10 +++++-----
 modules/stream_filter/dash/xml/DOMHelper.h   |    6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/modules/stream_filter/dash/xml/DOMHelper.cpp b/modules/stream_filter/dash/xml/DOMHelper.cpp
index 52f97dd..3abbf39 100644
--- a/modules/stream_filter/dash/xml/DOMHelper.cpp
+++ b/modules/stream_filter/dash/xml/DOMHelper.cpp
@@ -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;
diff --git a/modules/stream_filter/dash/xml/DOMHelper.h b/modules/stream_filter/dash/xml/DOMHelper.h
index 775b8f3..97bb897 100644
--- a/modules/stream_filter/dash/xml/DOMHelper.h
+++ b/modules/stream_filter/dash/xml/DOMHelper.h
@@ -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);
         };
     }
 }



More information about the vlc-commits mailing list