[Rpm-maint] [PATCH] avoid redundant processing for RemovePathPostfixes:

Pádraig Brady P at draigBrady.com
Thu Nov 19 13:38:19 UTC 2015


* build/files.c (genCpioListAndHeader): Only iterate over
the file list if RemovePathPostfixes: has been specified.
Also don't bother reallocating the paths and the existing
path modified in place will suffice.
---
 build/files.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/build/files.c b/build/files.c
index 2fc434e..4d49449 100644
--- a/build/files.c
+++ b/build/files.c
@@ -930,29 +930,22 @@ static void genCpioListAndHeader(FileList fl, Package pkg, int isSrc)
 		digestalgo);
 	digestalgo = defaultalgo;
     }
-    
+
     /* Adjust paths if needed */
+    if (!isSrc && pkg->removePostfixes)
     for (i = 0, flp = fl->files.recs; i < fl->files.used; i++, flp++) {
-	int changed = 0;
 	char * cpiopath = flp->cpioPath;
 
-	if (!isSrc && pkg->removePostfixes)
 	for (ARGV_const_t postfix_p = pkg->removePostfixes; *postfix_p; postfix_p++) {
 	    int len = strlen(*postfix_p);
 	    int plen = strlen(cpiopath);
 	    if (len <= plen && !strncmp(cpiopath+plen-len, *postfix_p, len)) {
 		cpiopath[plen-len] = '\0';
-		changed = 1;
 		if (plen-len > 0 && cpiopath[plen-len-1] == '/') {
 		    cpiopath[plen-len-1] = '\0';
 		}
 	    }
 	}
-	if (changed) {
-	    char * tmp = xstrdup(cpiopath);
-	    _free(flp->cpioPath);
-	    flp->cpioPath = tmp;
-	}
     }
 
     /* Sort the big list */
-- 
2.5.0



More information about the Rpm-maint mailing list