From af80c3de47278c0631f1add3da56758343fafe44 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Thu, 28 Aug 2008 16:06:36 +0200 Subject: [PATCH] Use only one, global fingerPrintCache to save a lot of stat calls --- lib/fprint.h | 3 ++- lib/rpmdb.c | 6 +----- lib/transaction.c | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/fprint.h b/lib/fprint.h index 64abe22..c500784 100644 --- a/lib/fprint.h +++ b/lib/fprint.h @@ -100,7 +100,8 @@ extern "C" { */ RPM_GNUC_INTERNAL int rpmdbFindFpList(rpmdb db, fingerPrint * fpList, - dbiIndexSet * matchList, int numItems); + dbiIndexSet * matchList, int numItems, + fingerPrintCache fpc); /* Be carefull with the memory... assert(*fullName == '/' || !scareMemory) */ diff --git a/lib/rpmdb.c b/lib/rpmdb.c index 0b1ac9e..bde76eb 100644 --- a/lib/rpmdb.c +++ b/lib/rpmdb.c @@ -2934,12 +2934,11 @@ static int skipDir(const char * dn) /* XXX transaction.c */ int rpmdbFindFpList(rpmdb db, fingerPrint * fpList, dbiIndexSet * matchList, - int numItems) + int numItems, fingerPrintCache fpc) { DBT * key; DBT * data; rpmdbMatchIterator mi; - fingerPrintCache fpc; Header h; int i, xx; @@ -2973,7 +2972,6 @@ int rpmdbFindFpList(rpmdb db, fingerPrint * fpList, dbiIndexSet * matchList, mi = rpmdbFreeIterator(mi); return 0; } - fpc = fpCacheCreate(i); rpmdbSortIterator(mi); /* iterator is now sorted by (recnum, filenum) */ @@ -3042,8 +3040,6 @@ int rpmdbFindFpList(rpmdb db, fingerPrint * fpList, dbiIndexSet * matchList, mi = rpmdbFreeIterator(mi); - fpc = fpCacheFree(fpc); - return 0; } diff --git a/lib/transaction.c b/lib/transaction.c index 447bb89..a9c4a91 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -1063,7 +1063,7 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet) ts->ht = rpmFpHashCreate(totalFileCount * 2, fpHashFunction, fpEqual, NULL, NULL); - fpc = fpCacheCreate(totalFileCount); + fpc = fpCacheCreate(totalFileCount * 2); /* =============================================== * Add fingerprint for each file not skipped. @@ -1148,7 +1148,7 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet) (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0); /* Extract file info for all files in this package from the database. */ matches = xcalloc(fc, sizeof(*matches)); - if (rpmdbFindFpList(rpmtsGetRdb(ts), fi->fps, matches, fc)) { + if (rpmdbFindFpList(rpmtsGetRdb(ts), fi->fps, matches, fc, fpc)) { ps = rpmpsFree(ps); rpmtsFreeLock(lock); return 1; /* XXX WTFO? */ -- 2.7.4