summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2012-09-03 11:16:13 +0300
committerPanu Matilainen <pmatilai@redhat.com>2012-09-03 14:24:12 +0300
commitd5dc69c18e5ec79db3c4ab26c948c92e399577be (patch)
tree22edf09588ecd0abb00c480572c5cb87692af3c1 /lib
parentf7f02fb6cbf0d048adb42acc9250868420f2d3e8 (diff)
downloadrpm-d5dc69c18e5ec79db3c4ab26c948c92e399577be.tar.gz
rpm-d5dc69c18e5ec79db3c4ab26c948c92e399577be.tar.bz2
rpm-d5dc69c18e5ec79db3c4ab26c948c92e399577be.zip
"Optimize" addFingerprints() a bit
- Avoid repeatedly calling rpmteGetFileStates() for every file processed - Avoid rpmfi iteration, use a good ole for-loop and index-accessors - Dont bother looking up symlinks for skipped files - Eliminate rpmfi from the latter loop, its not used for anything there - Not that this is going to show on wall-clock times, the cycles saved here are going to get very much lost in the noise of more expensive things.
Diffstat (limited to 'lib')
-rw-r--r--lib/transaction.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/transaction.c b/lib/transaction.c
index 0d8e0561b..8f4ccb6c5 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -1226,8 +1226,9 @@ static void addFingerprints(rpmts ts, uint64_t fileCount, rpmFpHash ht, fingerPr
{
rpmtsi pi;
rpmte p;
+ rpmfs fs;
rpmfi fi;
- int i;
+ int i, fc;
rpmFpHash symlinks = rpmFpHashCreate(fileCount/16+16, fpHashFunction, fpEqual, NULL, NULL);
@@ -1240,21 +1241,22 @@ static void addFingerprints(rpmts ts, uint64_t fileCount, rpmFpHash ht, fingerPr
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
rpmfiFpLookup(fi, fpc);
+ fs = rpmteGetFileStates(p);
+ fc = rpmfsFC(fs);
/* collect symbolic links */
- fi = rpmfiInit(fi, 0);
- while ((i = rpmfiNext(fi)) >= 0) {
+ for (i = 0; i < fc; i++) {
struct rpmffi_s ffi;
char const *linktarget;
- linktarget = rpmfiFLink(fi);
- if (!(linktarget && *linktarget != '\0'))
+ if (XFA_SKIPPING(rpmfsGetAction(fs, i)))
continue;
- if (XFA_SKIPPING(rpmfsGetAction(rpmteGetFileStates(p), i)))
+ linktarget = rpmfiFLinkIndex(fi, i);
+ if (!(linktarget && *linktarget != '\0'))
continue;
ffi.p = p;
ffi.fileno = i;
rpmFpHashAddEntry(symlinks, rpmfiFpsIndex(fi, i), ffi);
}
- (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), rpmfiFC(fi));
+ (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), fc);
}
rpmtsiFree(pi);
@@ -1268,10 +1270,11 @@ static void addFingerprints(rpmts ts, uint64_t fileCount, rpmFpHash ht, fingerPr
while ((p = rpmtsiNext(pi, 0)) != NULL) {
(void) rpmdbCheckSignals();
- fi = rpmfiInit(rpmteFI(p), 0);
+ fs = rpmteGetFileStates(p);
+ fc = rpmfsFC(fs);
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
- while ((i = rpmfiNext(fi)) >= 0) {
- if (XFA_SKIPPING(rpmfsGetAction(rpmteGetFileStates(p), i)))
+ for (i = 0; i < fc; i++) {
+ if (XFA_SKIPPING(rpmfsGetAction(fs, i)))
continue;
fpLookupSubdir(symlinks, ht, fpc, p, i);
}