[vlc-devel] commit: Skins2: Cosmetics and drop const from string return as there really is no point: We're returning a fresh object. (JP Dinger )

git version control git at videolan.org
Sat Dec 5 22:35:15 CET 2009


vlc | branch: master | JP Dinger <jpd at videolan.org> | Tue Nov 24 10:42:39 2009 +0100| [77aa98d05aefe480e39a9fbb8c482e4de4c78855] | committer: JP Dinger 

Skins2: Cosmetics and drop const from string return as there really is no point: We're returning a fresh object.

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

 modules/gui/skins2/vars/time.cpp |   48 +++++++++++++++++++-------------------
 modules/gui/skins2/vars/time.hpp |   10 ++++----
 2 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/modules/gui/skins2/vars/time.cpp b/modules/gui/skins2/vars/time.cpp
index 5290c8a..3adec76 100644
--- a/modules/gui/skins2/vars/time.cpp
+++ b/modules/gui/skins2/vars/time.cpp
@@ -42,7 +42,7 @@ void StreamTime::set( float percentage, bool updateVLC )
 }
 
 
-const string StreamTime::getAsStringPercent() const
+string StreamTime::getAsStringPercent() const
 {
     int value = (int)(100. * get());
     // 0 <= value <= 100, so we need 4 chars
@@ -52,7 +52,27 @@ const string StreamTime::getAsStringPercent() const
 }
 
 
-const string StreamTime::getAsStringCurrTime( bool bShortFormat ) const
+string StreamTime::formatTime( int seconds, bool bShortFormat ) const
+{
+    char psz_time[MSTRTIME_MAX_SIZE];
+    if( bShortFormat && (seconds < 60 * 60) )
+    {
+        snprintf( psz_time, MSTRTIME_MAX_SIZE, "%02d:%02d",
+                  (int) (seconds / 60 % 60),
+                  (int) (seconds % 60) );
+    }
+    else
+    {
+        snprintf( psz_time, MSTRTIME_MAX_SIZE, "%d:%02d:%02d",
+                  (int) (seconds / (60 * 60)),
+                  (int) (seconds / 60 % 60),
+                  (int) (seconds % 60) );
+    }
+    return string(psz_time);
+}
+
+
+string StreamTime::getAsStringCurrTime( bool bShortFormat ) const
 {
     if( !havePosition() )
         return "-:--:--";
@@ -62,7 +82,7 @@ const string StreamTime::getAsStringCurrTime( bool bShortFormat ) const
 }
 
 
-const string StreamTime::getAsStringTimeLeft( bool bShortFormat ) const
+string StreamTime::getAsStringTimeLeft( bool bShortFormat ) const
 {
     if( !havePosition() )
         return "-:--:--";
@@ -74,7 +94,7 @@ const string StreamTime::getAsStringTimeLeft( bool bShortFormat ) const
 }
 
 
-const string StreamTime::getAsStringDuration( bool bShortFormat ) const
+string StreamTime::getAsStringDuration( bool bShortFormat ) const
 {
     if( !havePosition() )
         return "-:--:--";
@@ -82,23 +102,3 @@ const string StreamTime::getAsStringDuration( bool bShortFormat ) const
     mtime_t time = var_GetTime( getIntf()->p_sys->p_input, "length" );
     return formatTime( time / 1000000, bShortFormat );
 }
-
-
-const string StreamTime::formatTime( int seconds, bool bShortFormat ) const
-{
-    char psz_time[MSTRTIME_MAX_SIZE];
-    if( bShortFormat && (seconds < 60 * 60) )
-    {
-        snprintf( psz_time, MSTRTIME_MAX_SIZE, "%02d:%02d",
-                  (int) (seconds / 60 % 60),
-                  (int) (seconds % 60) );
-    }
-    else
-    {
-        snprintf( psz_time, MSTRTIME_MAX_SIZE, "%d:%02d:%02d",
-                  (int) (seconds / (60 * 60)),
-                  (int) (seconds / 60 % 60),
-                  (int) (seconds % 60) );
-    }
-    return string(psz_time);
-}
diff --git a/modules/gui/skins2/vars/time.hpp b/modules/gui/skins2/vars/time.hpp
index f82a30d..f23f6cf 100644
--- a/modules/gui/skins2/vars/time.hpp
+++ b/modules/gui/skins2/vars/time.hpp
@@ -40,17 +40,17 @@ public:
     virtual void set( float percentage ) { set( percentage, true ); }
 
     /// Return a string containing a value from 0 to 100
-    virtual const string getAsStringPercent() const;
+    virtual string getAsStringPercent() const;
     /// Return the current time formatted as a time display (h:mm:ss)
-    virtual const string getAsStringCurrTime( bool bShortFormat = false ) const;
+    virtual string getAsStringCurrTime( bool bShortFormat = false ) const;
     /// Return the time left formatted as a time display (h:mm:ss)
-    virtual const string getAsStringTimeLeft( bool bShortFormat = false ) const;
+    virtual string getAsStringTimeLeft( bool bShortFormat = false ) const;
     /// Return the duration formatted as a time display (h:mm:ss)
-    virtual const string getAsStringDuration( bool bShortFormat = false ) const;
+    virtual string getAsStringDuration( bool bShortFormat = false ) const;
 
 private:
     /// Convert a number of seconds into "h:mm:ss" format
-    const string formatTime( int seconds, bool bShortFormat ) const;
+    string formatTime( int seconds, bool bShortFormat ) const;
     /// Return true when there is a non-null input and its position is not 0.0.
     bool havePosition() const;
 };




More information about the vlc-devel mailing list