[vlc-commits] [Git][videolan/vlc][master] 12 commits: skins2: art_manager: pass by ref instead of copying

Tristan Matthews (@tmatth) gitlab at videolan.org
Mon Oct 20 15:52:40 UTC 2025



Tristan Matthews pushed to branch master at VideoLAN / VLC


Commits:
41809f0b by Tristan Matthews at 2025-10-20T14:02:24+00:00
skins2: art_manager: pass by ref instead of copying

Fixes CID 1666395, CID 1666360, CID 1666325

- - - - -
a2655ef8 by Tristan Matthews at 2025-10-20T14:02:24+00:00
skins2: art_manager: constify

- - - - -
c447e204 by Tristan Matthews at 2025-10-20T14:02:24+00:00
skins2: skin_parser: move instead of copying

Fixes CID 1666395, CID 1666385

- - - - -
b13833fc by Tristan Matthews at 2025-10-20T14:02:24+00:00
skins2: skin_parser: pass by const ref instead of copying

Also constify or convert to a static helper where appropriate.

Fixes CID 1666380, CID 1666372, CID 1666366, CID 1666365

- - - - -
ed52b9d9 by Tristan Matthews at 2025-10-20T14:02:24+00:00
skins2: skin_parser: drop redundant const qualifiers

There's no point of having const on the return type since it's being returned by copy.

- - - - -
14a14621 by Tristan Matthews at 2025-10-20T14:02:24+00:00
skins2: x11: move instead of copying

Fixes CID 1666379

- - - - -
6635c94e by Tristan Matthews at 2025-10-20T14:02:24+00:00
skins2: file_bitmap: pass by ref instead of copying

Fixes CID 1666361

- - - - -
4ccaac04 by Tristan Matthews at 2025-10-20T14:02:24+00:00
skins2: fsm: move instead of copying

Fixes CID 1666358

- - - - -
622c436d by Tristan Matthews at 2025-10-20T14:02:24+00:00
skins2: theme_loader: move instead of copying

Fixes CID 1666352

- - - - -
1ae7707b by Tristan Matthews at 2025-10-20T14:02:24+00:00
skins2: cmd_callbacks: pass by ref instead of copying

Fixes CID 1666350, CID 1666327

- - - - -
cf308188 by Tristan Matthews at 2025-10-20T14:02:24+00:00
skins2: parser: move instead of copying

Fixes CID 1666358

- - - - -
5e065cfa by Tristan Matthews at 2025-10-20T14:02:24+00:00
skins2: utils: pass by ref instead of copying

Fixes CID 1666328

- - - - -


13 changed files:

- modules/gui/skins2/commands/cmd_callbacks.hpp
- modules/gui/skins2/parser/expr_evaluator.cpp
- modules/gui/skins2/parser/skin_parser.cpp
- modules/gui/skins2/parser/skin_parser.hpp
- modules/gui/skins2/src/art_manager.cpp
- modules/gui/skins2/src/art_manager.hpp
- modules/gui/skins2/src/file_bitmap.cpp
- modules/gui/skins2/src/file_bitmap.hpp
- modules/gui/skins2/src/theme_loader.cpp
- modules/gui/skins2/utils/fsm.cpp
- modules/gui/skins2/utils/var_string.cpp
- modules/gui/skins2/utils/var_string.hpp
- modules/gui/skins2/x11/x11_dragdrop.cpp


Changes:

=====================================
modules/gui/skins2/commands/cmd_callbacks.hpp
=====================================
@@ -34,7 +34,7 @@ class CmdCallback : public CmdGeneric
 public:
     CmdCallback( intf_thread_t *pIntf, vlc_value_t newVal,
                  void (VlcProc::*func)(vlc_value_t),
-                 std::string label )
+                 const std::string &label )
         : CmdGeneric( pIntf ), m_newVal( newVal ),
           m_label( label ), m_pfExecute( func )
     {


=====================================
modules/gui/skins2/parser/expr_evaluator.cpp
=====================================
@@ -87,7 +87,7 @@ void ExprEvaluator::parse( const std::string &rExpr )
                     // Pop the stack
                     std::string lastOp = opStack.back();
                     opStack.pop_back();
-                    m_stack.push_back( lastOp );
+                    m_stack.push_back( std::move(lastOp) );
                 }
                 opStack.push_back( token );
             }


=====================================
modules/gui/skins2/parser/skin_parser.cpp
=====================================
@@ -387,7 +387,7 @@ void SkinParser::handleBeginElement( const std::string &rName, AttrList_t &attr
         m_curLayer++;
         m_pData->m_listPanel.push_back( panel );
         // Add the panel to the stack
-        m_panelStack.push_back( panelId );
+        m_panelStack.push_back( std::move(panelId) );
     }
 
     else if( rName == "Playlist" )
@@ -831,7 +831,7 @@ int SkinParser::convertInRange( const char *value, int minValue, int maxValue,
 }
 
 
-const std::string SkinParser::generateId() const
+std::string SkinParser::generateId() const
 {
     static int i = 1;
 
@@ -844,7 +844,7 @@ const std::string SkinParser::generateId() const
 }
 
 
-const std::string SkinParser::uniqueId( const std::string &id )
+std::string SkinParser::uniqueId( const std::string &id )
 {
     std::string newId;
 
@@ -869,7 +869,7 @@ const std::string SkinParser::uniqueId( const std::string &id )
     return newId;
 }
 
-void SkinParser::getRefDimensions( int &rWidth, int &rHeight, bool toScreen )
+void SkinParser::getRefDimensions( int &rWidth, int &rHeight, bool toScreen ) const
 {
     if( toScreen )
     {
@@ -905,7 +905,7 @@ void SkinParser::getRefDimensions( int &rWidth, int &rHeight, bool toScreen )
 }
 
 
-int SkinParser::getDimension( std::string value, int refDimension )
+int SkinParser::getDimension( const std::string &value, int refDimension )
 {
     std::string::size_type leftPos;
 
@@ -927,7 +927,7 @@ int SkinParser::getDimension( std::string value, int refDimension )
 }
 
 
-int SkinParser::getPosition( std::string position )
+int SkinParser::getPosition( const std::string &position ) const
 {
     if( position == "-1" )
         return POS_UNDEF;
@@ -956,10 +956,10 @@ int SkinParser::getPosition( std::string position )
 }
 
 
-void SkinParser::convertPosition( std::string position, std::string xOffset,
-                          std::string yOffset, std::string xMargin,
-                          std::string yMargin, int width, int height,
-                          int refWidth, int refHeight, int* p_x, int* p_y )
+void SkinParser::convertPosition( const std::string &position, const std::string &xOffset,
+                          const std::string &yOffset, const std::string &xMargin,
+                          const std::string &yMargin, int width, int height,
+                          int refWidth, int refHeight, int* p_x, int* p_y ) const
 {
     int iPosition = getPosition( position );
     if( iPosition != POS_UNDEF )
@@ -1017,5 +1017,5 @@ void SkinParser::updateWindowPos( int width, int height )
                      width, height, refWidth, refHeight,
                      &win.m_xPos, &win.m_yPos );
 
-    m_pData->m_listWindow.push_back( win );
+    m_pData->m_listWindow.push_back( std::move(win) );
 }


=====================================
modules/gui/skins2/parser/skin_parser.hpp
=====================================
@@ -91,22 +91,22 @@ private:
     //@}
 
     /// Generate a new id
-    const std::string generateId() const;
+    std::string generateId() const;
 
     /// Check if the id is unique, and if not generate a new one
-    const std::string uniqueId( const std::string &id );
+    std::string uniqueId( const std::string &id );
 
     /// Management of relative positions
-    void getRefDimensions( int &rWidth, int &rHeight, bool toScreen );
-    int getDimension( std::string value, int refDimension );
-    int getPosition( std::string value );
+    void getRefDimensions( int &rWidth, int &rHeight, bool toScreen ) const;
+    static int getDimension( const std::string &value, int refDimension );
+    int getPosition( const std::string &value ) const;
     void updateWindowPos( int width, int height );
 
-    void convertPosition( std::string position,
-                          std::string xOffset, std::string yOffset,
-                          std::string xMargin, std::string yMargin,
+    void convertPosition( const std::string &position,
+                          const std::string &xOffset, const std::string &yOffset,
+                          const std::string &xMargin, const std::string &yMargin,
                           int width, int height, int refWidth, int refHeight,
-                          int* p_x, int* p_y );
+                          int* p_x, int* p_y ) const;
 
     /// Helper for handleBeginElement: Provide default attribute if missing.
     static void DefaultAttr( AttrList_t &attr, const char *a, const char *b )


=====================================
modules/gui/skins2/src/art_manager.cpp
=====================================
@@ -69,13 +69,13 @@ ArtManager::~ArtManager( )
     }
 
     std::list<ArtBitmap*>::const_iterator it;
-    for( it = m_listBitmap.begin(); it != m_listBitmap.end(); ++it )
+    for( it = m_listBitmap.cbegin(); it != m_listBitmap.cend(); ++it )
         delete *it;
     m_listBitmap.clear();
 }
 
 
-ArtBitmap* ArtManager::getArtBitmap( std::string uriName )
+ArtBitmap* ArtManager::getArtBitmap( const std::string &uriName )
 {
     if( !uriName.size() )
         return NULL;
@@ -85,7 +85,7 @@ ArtBitmap* ArtManager::getArtBitmap( std::string uriName )
 
     // check whether art is already loaded
     std::list<ArtBitmap*>::const_iterator it;
-    for( it = m_listBitmap.begin(); it != m_listBitmap.end(); ++it )
+    for( it = m_listBitmap.cbegin(); it != m_listBitmap.cend(); ++it )
     {
         if( (*it)->getUriName() == uriName )
             return *it;


=====================================
modules/gui/skins2/src/art_manager.hpp
=====================================
@@ -33,11 +33,11 @@ class ArtBitmap: public FileBitmap
 {
 public:
 
-    std::string getUriName() { return m_uriName; }
+    std::string getUriName() const { return m_uriName; }
 
     /// Constructor/destructor
     ArtBitmap( intf_thread_t *pIntf, image_handler_t *pImageHandler,
-               std::string uriName ) :
+               const std::string &uriName ) :
         FileBitmap( pIntf, pImageHandler, uriName, -1 ),
         m_uriName( uriName ) {}
     virtual ~ArtBitmap() {}
@@ -60,7 +60,7 @@ public:
     static void destroy( intf_thread_t *pIntf );
 
     /// Retrieve for the art file from uri name
-    ArtBitmap* getArtBitmap( std::string uriName );
+    ArtBitmap* getArtBitmap( const std::string &uriName );
 
 protected:
     // Protected because it is a singleton


=====================================
modules/gui/skins2/src/file_bitmap.cpp
=====================================
@@ -31,7 +31,7 @@
 #include "file_bitmap.hpp"
 
 FileBitmap::FileBitmap( intf_thread_t *pIntf, image_handler_t *pImageHandler,
-                        std::string fileName, uint32_t aColor, int nbFrames,
+                        const std::string &fileName, uint32_t aColor, int nbFrames,
                         int fps, int nbLoops ):
     GenericBitmap( pIntf, nbFrames, fps, nbLoops ), m_width( 0 ), m_height( 0 ),
     m_pData( NULL )
@@ -42,16 +42,18 @@ FileBitmap::FileBitmap( intf_thread_t *pIntf, image_handler_t *pImageHandler,
 
     video_format_Init( &fmt_out, VLC_CODEC_RGBA );
 
+    std::string uriName = fileName;
+
     if( strstr( fileName.c_str(), "://" ) == NULL )
     {
         char *psz_uri = vlc_path2uri( fileName.c_str(), NULL );
         if( !psz_uri )
             return;
-        fileName = psz_uri;
+        uriName = psz_uri;
         free( psz_uri );
     }
 
-    pPic = image_ReadUrl( pImageHandler, fileName.c_str(), &fmt_out );
+    pPic = image_ReadUrl( pImageHandler, uriName.c_str(), &fmt_out );
     if( !pPic )
     {
         video_format_Clean( &fmt_out );


=====================================
modules/gui/skins2/src/file_bitmap.hpp
=====================================
@@ -35,7 +35,7 @@ public:
     /// Load a bitmap from a file. aColor is the transparency
     /// color, in the format 0xRRGGBB
     FileBitmap( intf_thread_t *pIntf, image_handler_t *pImageHandler,
-                std::string fileName, uint32_t aColor, int nbFrames = 1,
+                const std::string &fileName, uint32_t aColor, int nbFrames = 1,
                 int fps = 0, int nbLoops = 0 );
 
     virtual ~FileBitmap();


=====================================
modules/gui/skins2/src/theme_loader.cpp
=====================================
@@ -365,7 +365,7 @@ bool ThemeLoader::findFile( const std::string &rootDir, const std::string &rFile
                 // Found the theme file?
                 if( rFileName == std::string( pszDirContent ) )
                 {
-                    themeFilePath = newURI;
+                    themeFilePath = std::move(newURI);
                     vlc_closedir( pCurrDir );
                     return true;
                 }


=====================================
modules/gui/skins2/utils/fsm.cpp
=====================================
@@ -53,7 +53,7 @@ void FSM::addTransition( const std::string &state1, const std::string &event,
         return;
     }
 
-    m_transitions[key] = data;
+    m_transitions[key] = std::move(data);
 }
 
 


=====================================
modules/gui/skins2/utils/var_string.cpp
=====================================
@@ -26,7 +26,7 @@
 const std::string VarString::m_type = "string";
 
 
-void VarString::set( std::string str )
+void VarString::set( const std::string &str )
 {
     // If the value has changed, notify the observers
     if( m_value != str )


=====================================
modules/gui/skins2/utils/var_string.hpp
=====================================
@@ -40,7 +40,7 @@ public:
     virtual const std::string &getType() const { return m_type; }
 
     /// Set the internal value
-    virtual void set( std::string str );
+    virtual void set( const std::string &str );
     virtual std::string get() const { return m_value; }
 
 private:


=====================================
modules/gui/skins2/x11/x11_dragdrop.cpp
=====================================
@@ -67,7 +67,7 @@ void X11DragDrop::dndEnter( ldata_t data )
         for( unsigned long i=0; i<nitems; i++ )
         {
             std::string dataType = XGetAtomName( XDISPLAY, dataList[i] );
-            dataTypes.push_back( dataType );
+            dataTypes.push_back( std::move(dataType) );
         }
         XFree( (void*)dataList );
     }
@@ -78,7 +78,7 @@ void X11DragDrop::dndEnter( ldata_t data )
             if( data[i] != None )
             {
                 std::string dataType = XGetAtomName( XDISPLAY, data[i] );
-                dataTypes.push_back( dataType );
+                dataTypes.push_back( std::move(dataType) );
             }
         }
     }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/cd94dcaec9493735ddf711a069af99870a15e8f9...5e065cfa02207a342d0f92bc9265a4ee20fd4fe8

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/cd94dcaec9493735ddf711a069af99870a15e8f9...5e065cfa02207a342d0f92bc9265a4ee20fd4fe8
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list