From ea3a8f1e427a33527ab22c1ba4940153a235e610 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 5 Sep 2012 16:36:16 +0300 Subject: 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... --- lib/rpmal.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib/rpmal.c') 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); } } -- cgit v1.2.3