[vlc-commits] dash: Avoid some copies.

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


vlc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Thu Nov 24 11:53:20 2011 +0100| [85ed6b991f2aff8490ee23dffd96b431ddc22e7c] | committer: Rémi Denis-Courmont

dash: Avoid some copies.

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

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

 modules/stream_filter/dash/mpd/MPD.cpp |   19 +++++++++++--------
 modules/stream_filter/dash/mpd/MPD.h   |   10 +++++-----
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/modules/stream_filter/dash/mpd/MPD.cpp b/modules/stream_filter/dash/mpd/MPD.cpp
index cb8c7e0..ce11efc 100644
--- a/modules/stream_filter/dash/mpd/MPD.cpp
+++ b/modules/stream_filter/dash/mpd/MPD.cpp
@@ -50,33 +50,36 @@ MPD::~MPD   ()
     delete(this->programInfo);
 }
 
-std::vector<Period*>    MPD::getPeriods             ()
+const std::vector<Period*>&    MPD::getPeriods             () const
 {
     return this->periods;
 }
-std::vector<BaseUrl*>   MPD::getBaseUrls            ()
+
+const std::vector<BaseUrl*>&   MPD::getBaseUrls            () const
 {
     return this->baseUrls;
 }
-std::string             MPD::getMinBufferTime       () throw(AttributeNotPresentException)
+
+const std::string&             MPD::getMinBufferTime       () const throw(AttributeNotPresentException)
 {
-    AttributesMap::iterator     it = this->attributes.find("minBufferTime");
+    AttributesMap::const_iterator     it = this->attributes.find("minBufferTime");
     if( it == this->attributes.end())
         throw AttributeNotPresentException();
 
     return it->second;
 }
-std::string             MPD::getType                () throw(AttributeNotPresentException)
+
+const std::string&             MPD::getType                () const throw(AttributeNotPresentException)
 {
-    AttributesMap::iterator     it = this->attributes.find( "type" );
+    AttributesMap::const_iterator     it = this->attributes.find( "type" );
     if( it == this->attributes.end() )
         throw AttributeNotPresentException();
 
     return it->second;
 }
-std::string             MPD::getDuration            () throw(AttributeNotPresentException)
+const std::string&             MPD::getDuration            () const throw(AttributeNotPresentException)
 {
-    AttributesMap::iterator     it = this->attributes.find("mediaPresentationDuration");
+    AttributesMap::const_iterator     it = this->attributes.find("mediaPresentationDuration");
 
     if( it == this->attributes.end())
         throw AttributeNotPresentException();
diff --git a/modules/stream_filter/dash/mpd/MPD.h b/modules/stream_filter/dash/mpd/MPD.h
index 2942b18..bb2f1d1 100644
--- a/modules/stream_filter/dash/mpd/MPD.h
+++ b/modules/stream_filter/dash/mpd/MPD.h
@@ -48,11 +48,11 @@ namespace dash
                 MPD         ();
                 virtual ~MPD();
 
-                std::string             getType                 () throw(dash::exception::AttributeNotPresentException);
-                std::string             getDuration             () throw(dash::exception::AttributeNotPresentException);
-                std::string             getMinBufferTime        () throw(dash::exception::AttributeNotPresentException);
-                std::vector<BaseUrl *>  getBaseUrls             ();
-                std::vector<Period *>   getPeriods              ();
+                const std::string&             getType                 () const throw(dash::exception::AttributeNotPresentException);
+                const std::string&             getDuration             () const throw(dash::exception::AttributeNotPresentException);
+                const std::string&             getMinBufferTime        () const throw(dash::exception::AttributeNotPresentException);
+                const std::vector<BaseUrl *>&  getBaseUrls      () const;
+                const std::vector<Period *>&   getPeriods       () const;
                 ProgramInformation*     getProgramInformation   () throw(dash::exception::ElementNotPresentException);
 
                 void    addPeriod               (Period *period);



More information about the vlc-commits mailing list