[vlc-devel] [PATCH] preparser: art: Remove useless copy

Hugo Beauzée-Luyssen hugo at beauzee.fr
Thu Dec 17 15:55:11 UTC 2020


The content is always owned by the called, and since the
ArtCacheCreateDir doesn't change the string content, we can simply use
the string passed in parameter without any need for a copy
---
 src/preparser/art.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/preparser/art.c b/src/preparser/art.c
index b7f0d48411..9fa9e66ba0 100644
--- a/src/preparser/art.c
+++ b/src/preparser/art.c
@@ -37,20 +37,17 @@
 
 #include "art.h"
 
-static void ArtCacheCreateDir( const char *psz_dir )
+static void ArtCacheCreateDir( char *psz_dir )
 {
-    char newdir[strlen( psz_dir ) + 1];
-    strcpy( newdir, psz_dir );
-    char * psz_newdir = newdir;
-    char * psz = psz_newdir;
+    char * psz = psz_dir;
 
     while( *psz )
     {
         while( *psz && *psz != DIR_SEP_CHAR) psz++;
         if( !*psz ) break;
         *psz = 0;
-        if( !EMPTY_STR( psz_newdir ) )
-            vlc_mkdir( psz_newdir, 0700 );
+        if( !EMPTY_STR( psz_dir ) )
+            vlc_mkdir( psz_dir, 0700 );
         *psz = DIR_SEP_CHAR;
         psz++;
     }
-- 
2.29.2



More information about the vlc-devel mailing list