summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2012-09-05 16:36:16 +0300
committerPanu Matilainen <pmatilai@redhat.com>2012-09-05 17:09:40 +0300
commitea3a8f1e427a33527ab22c1ba4940153a235e610 (patch)
tree709627aef2f0a07fc554cc7c57d0a5587088e646
parent712101ba98c0e1c588652cef9b39ac5707c2f61c (diff)
downloadlibrpm-tizen-ea3a8f1e427a33527ab22c1ba4940153a235e610.tar.gz
librpm-tizen-ea3a8f1e427a33527ab22c1ba4940153a235e610.tar.bz2
librpm-tizen-ea3a8f1e427a33527ab22c1ba4940153a235e610.zip
Avoid rehashing directory name when it doesn't change in rpmal population
- Another modest improvement in redundant rehashing elimination, but in the big picture, this is really just another fart in the Sahara desert...
-rw-r--r--lib/rpmal.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/rpmal.c b/lib/rpmal.c
index 8d5446d57..420512af4 100644
--- a/lib/rpmal.c
+++ b/lib/rpmal.c
@@ -167,6 +167,8 @@ static void rpmalAddFiles(rpmal al, rpmalNum pkgNum, rpmfi fi)
rpm_color_t ficolor;
int skipdoc = (al->tsflags & RPMTRANS_FLAG_NODOCS);
int skipconf = (al->tsflags & RPMTRANS_FLAG_NOCONFIGS);
+ const char *prevDir = NULL;
+ unsigned int dirHash, fnHash;
fileEntry.pkgNum = pkgNum;
@@ -186,9 +188,16 @@ static void rpmalAddFiles(rpmal al, rpmalNum pkgNum, rpmfi fi)
fileName.dirName = rpmfiDN(fi);
fileName.baseName = rpmfiBN(fi);
+ /* Avoid rehash on dirname when directory remains the same */
+ if (fileName.dirName != prevDir) {
+ dirHash = rstrhash(fileName.dirName);
+ prevDir = fileName.dirName;
+ }
+ fnHash = dirHash ^ rstrhash(fileName.baseName);
+
fileEntry.entryIx = i;
- rpmalFileHashAddEntry(al->fileHash, fileName, fileEntry);
+ rpmalFileHashAddHEntry(al->fileHash, fileName, fnHash, fileEntry);
}
}