[vlc-commits] dash: Avoid some copies & useless initializations

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


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

dash: Avoid some copies & useless initializations

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

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

 modules/stream_filter/dash/mpd/BasicCMManager.cpp |    3 ++-
 modules/stream_filter/dash/mpd/BasicCMManager.h   |    2 +-
 modules/stream_filter/dash/mpd/IMPDManager.h      |    2 +-
 modules/stream_filter/dash/mpd/NullManager.cpp    |    6 +++---
 modules/stream_filter/dash/mpd/NullManager.h      |    6 +++++-
 5 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/modules/stream_filter/dash/mpd/BasicCMManager.cpp b/modules/stream_filter/dash/mpd/BasicCMManager.cpp
index 7f22495..5cd8b7a 100644
--- a/modules/stream_filter/dash/mpd/BasicCMManager.cpp
+++ b/modules/stream_filter/dash/mpd/BasicCMManager.cpp
@@ -60,10 +60,11 @@ std::vector<ISegment*>  BasicCMManager::getSegments             (Representation
 
     return retSegments;
 }
-std::vector<Period*>    BasicCMManager::getPeriods              ()
+const std::vector<Period*>&    BasicCMManager::getPeriods              () const
 {
     return this->mpd->getPeriods();
 }
+
 Representation*         BasicCMManager::getBestRepresentation   (Period *period)
 {
     std::vector<Group *> groups = period->getGroups();
diff --git a/modules/stream_filter/dash/mpd/BasicCMManager.h b/modules/stream_filter/dash/mpd/BasicCMManager.h
index 9c399c9..ee8072a 100644
--- a/modules/stream_filter/dash/mpd/BasicCMManager.h
+++ b/modules/stream_filter/dash/mpd/BasicCMManager.h
@@ -51,7 +51,7 @@ namespace dash
                 BasicCMManager          (MPD *mpd);
                 virtual ~BasicCMManager ();
 
-                std::vector<Period *>   getPeriods              ();
+                const std::vector<Period *>&   getPeriods              () const;
                 Period*                 getFirstPeriod          ();
                 Period*                 getNextPeriod           (Period *period);
                 Representation*         getBestRepresentation   (Period *period);
diff --git a/modules/stream_filter/dash/mpd/IMPDManager.h b/modules/stream_filter/dash/mpd/IMPDManager.h
index 1c2b5c7..c5a3e6e 100644
--- a/modules/stream_filter/dash/mpd/IMPDManager.h
+++ b/modules/stream_filter/dash/mpd/IMPDManager.h
@@ -26,7 +26,7 @@ namespace dash
         class IMPDManager
         {
             public:
-                virtual std::vector<Period *>   getPeriods              ()                              = 0;
+                virtual const std::vector<Period *>&   getPeriods              () const                 = 0;
                 virtual Period*                 getFirstPeriod          ()                              = 0;
                 virtual Period*                 getNextPeriod           (Period *period)                = 0;
                 virtual Representation*         getBestRepresentation   (Period *period)                = 0;
diff --git a/modules/stream_filter/dash/mpd/NullManager.cpp b/modules/stream_filter/dash/mpd/NullManager.cpp
index ff1262e..e7fa6ce 100644
--- a/modules/stream_filter/dash/mpd/NullManager.cpp
+++ b/modules/stream_filter/dash/mpd/NullManager.cpp
@@ -37,9 +37,9 @@ NullManager::~NullManager   ()
 {
 }
 
-std::vector<Period *>   NullManager::getPeriods              ()
+const std::vector<Period *>&   NullManager::getPeriods              () const
 {
-    return std::vector<Period *>();
+    return this->periods;
 }
 Period*                 NullManager::getFirstPeriod          ()
 {
@@ -55,7 +55,7 @@ Representation*         NullManager::getBestRepresentation   (Period *)
 }
 std::vector<ISegment *> NullManager::getSegments             (Representation *)
 {
-    return std::vector<ISegment *>();
+    return this->segments;
 }
 Representation*         NullManager::getRepresentation       (Period *, long )
 {
diff --git a/modules/stream_filter/dash/mpd/NullManager.h b/modules/stream_filter/dash/mpd/NullManager.h
index fc17bfa..361ef07 100644
--- a/modules/stream_filter/dash/mpd/NullManager.h
+++ b/modules/stream_filter/dash/mpd/NullManager.h
@@ -42,12 +42,16 @@ namespace dash
                 NullManager         ();
                 virtual ~NullManager();
 
-                std::vector<Period *>   getPeriods              ();
+                const std::vector<Period *>&   getPeriods              () const;
                 Period*                 getFirstPeriod          ();
                 Period*                 getNextPeriod           (Period *period);
                 Representation*         getBestRepresentation   (Period *period);
                 std::vector<ISegment *> getSegments             (Representation *rep);
                 Representation*         getRepresentation       (Period *period, long bitrate);
+
+            private:
+                std::vector<Period *>   periods;
+                std::vector<ISegment *> segments;
         };
     }
 }



More information about the vlc-commits mailing list