teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone
Blob Blame History Raw
From c32af0184db82f74bf506873ec9a69970299dd18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Thu, 19 Nov 2015 13:38:19 +0000
Subject: [PATCH] Avoid redundant processing for RemovePathPostfixes

Only iterate over the file list if RemovePathPostfixes: has been specified.
Also don't bother reallocating the paths as the existing path modified in
place will suffice.

(cherry picked from commit 8e8571a7f33d1ecc5a0c0b62196fd79b26a6052e)
---
 build/files.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/build/files.c b/build/files.c
index 29274926c..9b1d2cd98 100644
--- a/build/files.c
+++ b/build/files.c
@@ -980,29 +980,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 */