diff options
author | Michael Schroeder <mls@suse.de> | 2020-02-14 15:54:32 +0100 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2020-02-24 11:38:13 +0200 |
commit | ba9718211d244eef0ac376f246f8ae828a6d37b0 (patch) | |
tree | 42dc16ef811c7502042b4d3618cf8258a7cec4b5 /lib/fprint.c | |
parent | 02e1f3bc3a7225dedf5bad2a67872644d95655aa (diff) | |
download | rpm-ba9718211d244eef0ac376f246f8ae828a6d37b0.tar.gz |
Reduce the number of calls to fpLookupSubdir()
If the entry/subdirid parts of the fingerprint are equal to the
ones of the last added fingerprint, we know that calling
fpLookupSubdir() will not modify anything. So skip the call in
that case.
Diffstat (limited to 'lib/fprint.c')
-rw-r--r-- | lib/fprint.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/fprint.c b/lib/fprint.c index bb624212b..213bd65ae 100644 --- a/lib/fprint.c +++ b/lib/fprint.c @@ -497,7 +497,7 @@ void fpCachePopulate(fingerPrintCache fpc, rpmts ts, int fileCount) */ pi = rpmtsiInit(ts); while ((p = rpmtsiNext(pi, 0)) != NULL) { - fingerPrint *fpList; + fingerPrint *fpList, *lastfp = NULL; (void) rpmsqPoll(); if ((fi = rpmteFiles(p)) == NULL) @@ -511,11 +511,17 @@ void fpCachePopulate(fingerPrintCache fpc, rpmts ts, int fileCount) struct rpmffi_s ffi; if (XFA_SKIPPING(rpmfsGetAction(fs, i))) continue; - if (havesymlinks) - fpLookupSubdir(symlinks, fpc, fpList + i); + if (havesymlinks) { + /* if the entry/subdirid matches the one from the + * last entry we do not need to call fpLookupSubdir */ + if (!lastfp || lastfp->entry != fpList[i].entry || + lastfp->subDirId != fpList[i].subDirId) + fpLookupSubdir(symlinks, fpc, fpList + i); + } ffi.p = p; ffi.fileno = i; rpmFpHashAddEntry(fpc->fp, fpList + i, ffi); + lastfp = fpList + i; } (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0); rpmfilesFree(fi); |