diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2012-08-30 10:19:26 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2012-08-30 10:40:20 +0300 |
commit | 1a3a4089def9b00790eeebd6f931c99a03a3d44b (patch) | |
tree | c219cf976eceb6523248af047f333f8d1832fdc1 | |
parent | a664b518d493c6e851d1c05f99150d52447c14e9 (diff) | |
download | librpm-tizen-1a3a4089def9b00790eeebd6f931c99a03a3d44b.tar.gz librpm-tizen-1a3a4089def9b00790eeebd6f931c99a03a3d44b.tar.bz2 librpm-tizen-1a3a4089def9b00790eeebd6f931c99a03a3d44b.zip |
Use file info set of removed packages instead of header fetches
- When we get rpmdb hits on files from packages that are to be removed
in the same transaction, we can use its existing file info set
to grab base- and directory names to avoid bunch of headerGet()'s
and consecutive rpmtd manipulation. In theory this should speed up
transactions where lots of packages get removed, in practise not
really - the big cost here is in loading the headers from db in the
first place, despite not being really needed.
-rw-r--r-- | lib/transaction.c | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/lib/transaction.c b/lib/transaction.c index 36fc22826..0d8e0561b 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -977,10 +977,13 @@ void checkInstalledFiles(rpmts ts, uint64_t fileCount, rpmFpHash ht, fingerPrint } h = headerLink(h); - headerGet(h, RPMTAG_BASENAMES, &bnames, hgflags); - headerGet(h, RPMTAG_DIRNAMES, &dnames, hgflags); - headerGet(h, RPMTAG_DIRINDEXES, &dindexes, hgflags); - headerGet(h, RPMTAG_FILESTATES, &ostates, hgflags); + /* For packages being removed we can use its rpmfi to avoid all this */ + if (!beingRemoved) { + headerGet(h, RPMTAG_BASENAMES, &bnames, hgflags); + headerGet(h, RPMTAG_DIRNAMES, &dnames, hgflags); + headerGet(h, RPMTAG_DIRINDEXES, &dindexes, hgflags); + headerGet(h, RPMTAG_FILESTATES, &ostates, hgflags); + } oldDir = NULL; /* loop over all interesting files in that package */ @@ -992,13 +995,18 @@ void checkInstalledFiles(rpmts ts, uint64_t fileCount, rpmFpHash ht, fingerPrint const char * baseName; fileNum = rpmdbGetIteratorFileNum(mi); - rpmtdSetIndex(&bnames, fileNum); - rpmtdSetIndex(&dindexes, fileNum); - rpmtdSetIndex(&dnames, *rpmtdGetUint32(&dindexes)); - rpmtdSetIndex(&ostates, fileNum); - - dirName = rpmtdGetString(&dnames); - baseName = rpmtdGetString(&bnames); + if (!beingRemoved) { + rpmtdSetIndex(&bnames, fileNum); + rpmtdSetIndex(&dindexes, fileNum); + rpmtdSetIndex(&dnames, *rpmtdGetUint32(&dindexes)); + rpmtdSetIndex(&ostates, fileNum); + + dirName = rpmtdGetString(&dnames); + baseName = rpmtdGetString(&bnames); + } else { + dirName = rpmfiDNIndex(otherFi, rpmfiDIIndex(otherFi, fileNum)); + baseName = rpmfiBNIndex(otherFi, fileNum); + } /* lookup finger print for this file */ if ( dirName == oldDir) { @@ -1040,10 +1048,12 @@ void checkInstalledFiles(rpmts ts, uint64_t fileCount, rpmFpHash ht, fingerPrint } while (newheader==h); otherFi = rpmfiFree(otherFi); - rpmtdFreeData(&ostates); - rpmtdFreeData(&bnames); - rpmtdFreeData(&dnames); - rpmtdFreeData(&dindexes); + if (!beingRemoved) { + rpmtdFreeData(&ostates); + rpmtdFreeData(&bnames); + rpmtdFreeData(&dnames); + rpmtdFreeData(&dindexes); + } headerFree(h); h = newheader; } |