]> git.sesse.net Git - vlc/commitdiff
dash: Avoid multiple lookups.
authorHugo Beauzée-Luyssen <beauze.h@gmail.com>
Thu, 24 Nov 2011 10:52:44 +0000 (11:52 +0100)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 24 Nov 2011 17:00:27 +0000 (19:00 +0200)
Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
modules/stream_filter/dash/mpd/MPD.cpp
modules/stream_filter/dash/mpd/MPD.h

index 69b4c05f17433c05e1bb2e4a933a6a4e410fa307..cb8c7e072298c25dc9cdcc28e645b0394e8eba91 100644 (file)
@@ -60,24 +60,28 @@ std::vector<BaseUrl*>   MPD::getBaseUrls            ()
 }
 std::string             MPD::getMinBufferTime       () throw(AttributeNotPresentException)
 {
-    if(this->attributes.find("minBufferTime") == this->attributes.end())
+    AttributesMap::iterator     it = this->attributes.find("minBufferTime");
+    if( it == this->attributes.end())
         throw AttributeNotPresentException();
 
-    return this->attributes["minBufferTime"];
+    return it->second;
 }
 std::string             MPD::getType                () throw(AttributeNotPresentException)
 {
-    if(this->attributes.find("type") == this->attributes.end())
+    AttributesMap::iterator     it = this->attributes.find( "type" );
+    if( it == this->attributes.end() )
         throw AttributeNotPresentException();
 
-    return this->attributes["type"];
+    return it->second;
 }
 std::string             MPD::getDuration            () throw(AttributeNotPresentException)
 {
-    if(this->attributes.find("mediaPresentationDuration") == this->attributes.end())
+    AttributesMap::iterator     it = this->attributes.find("mediaPresentationDuration");
+
+    if( it == this->attributes.end())
         throw AttributeNotPresentException();
 
-    return this->attributes["mediaPresentationDuration"];
+    return it->second;
 }
 ProgramInformation*     MPD::getProgramInformation  () throw(ElementNotPresentException)
 {
index 732d38b3ad7de217ef20b64522137d54eed89d3a..2942b182746da999115a3baa845ca973051e5ab2 100644 (file)
@@ -41,6 +41,8 @@ namespace dash
     {
         class MPD
         {
+            typedef std::map<std::string, std::string>      AttributesMap;
+
             public:
                 MPD         (std::map<std::string, std::string> attributes);
                 MPD         ();
@@ -58,7 +60,7 @@ namespace dash
                 void    setProgramInformation   (ProgramInformation *progInfo);
 
             private:
-                std::map<std::string, std::string>  attributes;
+                AttributesMap                       attributes;
                 std::vector<Period *>               periods;
                 std::vector<BaseUrl *>              baseUrls;
                 ProgramInformation                  *programInfo;