Igor Gnatenko 53960f
From c32af0184db82f74bf506873ec9a69970299dd18 Mon Sep 17 00:00:00 2001
Igor Gnatenko 53960f
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Igor Gnatenko 53960f
Date: Thu, 19 Nov 2015 13:38:19 +0000
Igor Gnatenko 53960f
Subject: [PATCH] Avoid redundant processing for RemovePathPostfixes
Igor Gnatenko 53960f
Igor Gnatenko 53960f
Only iterate over the file list if RemovePathPostfixes: has been specified.
Igor Gnatenko 53960f
Also don't bother reallocating the paths as the existing path modified in
Igor Gnatenko 53960f
place will suffice.
Igor Gnatenko 53960f
Igor Gnatenko 53960f
(cherry picked from commit 8e8571a7f33d1ecc5a0c0b62196fd79b26a6052e)
Igor Gnatenko 53960f
---
Igor Gnatenko 53960f
 build/files.c | 11 ++---------
Igor Gnatenko 53960f
 1 file changed, 2 insertions(+), 9 deletions(-)
Igor Gnatenko 53960f
Igor Gnatenko 53960f
diff --git a/build/files.c b/build/files.c
Igor Gnatenko 53960f
index 29274926c..9b1d2cd98 100644
Igor Gnatenko 53960f
--- a/build/files.c
Igor Gnatenko 53960f
+++ b/build/files.c
Igor Gnatenko 53960f
@@ -980,29 +980,22 @@ static void genCpioListAndHeader(FileList fl, Package pkg, int isSrc)
Igor Gnatenko 53960f
 		digestalgo);
Igor Gnatenko 53960f
 	digestalgo = defaultalgo;
Igor Gnatenko 53960f
     }
Igor Gnatenko 53960f
-    
Igor Gnatenko 53960f
+
Igor Gnatenko 53960f
     /* Adjust paths if needed */
Igor Gnatenko 53960f
+    if (!isSrc && pkg->removePostfixes)
Igor Gnatenko 53960f
     for (i = 0, flp = fl->files.recs; i < fl->files.used; i++, flp++) {
Igor Gnatenko 53960f
-	int changed = 0;
Igor Gnatenko 53960f
 	char * cpiopath = flp->cpioPath;
Igor Gnatenko 53960f
 
Igor Gnatenko 53960f
-	if (!isSrc && pkg->removePostfixes)
Igor Gnatenko 53960f
 	for (ARGV_const_t postfix_p = pkg->removePostfixes; *postfix_p; postfix_p++) {
Igor Gnatenko 53960f
 	    int len = strlen(*postfix_p);
Igor Gnatenko 53960f
 	    int plen = strlen(cpiopath);
Igor Gnatenko 53960f
 	    if (len <= plen && !strncmp(cpiopath+plen-len, *postfix_p, len)) {
Igor Gnatenko 53960f
 		cpiopath[plen-len] = '\0';
Igor Gnatenko 53960f
-		changed = 1;
Igor Gnatenko 53960f
 		if (plen-len > 0 && cpiopath[plen-len-1] == '/') {
Igor Gnatenko 53960f
 		    cpiopath[plen-len-1] = '\0';
Igor Gnatenko 53960f
 		}
Igor Gnatenko 53960f
 	    }
Igor Gnatenko 53960f
 	}
Igor Gnatenko 53960f
-	if (changed) {
Igor Gnatenko 53960f
-	    char * tmp = xstrdup(cpiopath);
Igor Gnatenko 53960f
-	    _free(flp->cpioPath);
Igor Gnatenko 53960f
-	    flp->cpioPath = tmp;
Igor Gnatenko 53960f
-	}
Igor Gnatenko 53960f
     }
Igor Gnatenko 53960f
 
Igor Gnatenko 53960f
     /* Sort the big list */