Permalink
Browse files

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.
  • Loading branch information...
pixelb authored and ffesti committed Nov 19, 2015
1 parent 029e1fb commit 8e8571a7f33d1ecc5a0c0b62196fd79b26a6052e
Showing with 2 additions and 9 deletions.
  1. +2 −9 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 */

0 comments on commit 8e8571a

Please sign in to comment.