diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2012-09-14 19:55:03 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2012-09-14 19:59:15 +0300 |
commit | 62fd585b2ecd85519d67cc7185077d1178aed040 (patch) | |
tree | 8de6f305519c64a3b6dda0671dad2bc8f5a5bd81 /lib/transaction.c | |
parent | efa7b1dc0c4bfb260c799b612b5c362e4f47b1fd (diff) | |
download | librpm-tizen-62fd585b2ecd85519d67cc7185077d1178aed040.tar.gz librpm-tizen-62fd585b2ecd85519d67cc7185077d1178aed040.tar.bz2 librpm-tizen-62fd585b2ecd85519d67cc7185077d1178aed040.zip |
Switch rpmdb basename finding to use pool id's instead of strings
- Ids are both faster to hash/compare and cheaper to store than string
pointers. Not a huge win but a win anyway...
Diffstat (limited to 'lib/transaction.c')
-rw-r--r-- | lib/transaction.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/transaction.c b/lib/transaction.c index 7eefdc7aa..c05d3af3b 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -875,10 +875,20 @@ static void skipInstallFiles(const rpmts ts, rpmte p) #undef HTDATATYPE #define HASHTYPE rpmStringSet -#define HTKEYTYPE const char * +#define HTKEYTYPE rpmsid #include "lib/rpmhash.H" #include "lib/rpmhash.C" +static unsigned int sidHash(rpmsid sid) +{ + return sid; +} + +static int sidCmp(rpmsid a, rpmsid b) +{ + return (a != b); +} + /* Get a rpmdbMatchIterator containing all files in * the rpmdb that share the basename with one from * the transaction. @@ -895,9 +905,10 @@ rpmdbMatchIterator rpmFindBaseNamesInDB(rpmts ts, uint64_t fileCount) rpmdbMatchIterator mi; int oc = 0; const char * baseName; + rpmsid baseNameId; rpmStringSet baseNames = rpmStringSetCreate(fileCount, - rstrhash, strcmp, NULL); + sidHash, sidCmp, NULL); mi = rpmdbNewIterator(rpmtsGetRdb(ts), RPMDBI_BASENAMES); @@ -911,18 +922,18 @@ rpmdbMatchIterator rpmFindBaseNamesInDB(rpmts ts, uint64_t fileCount) fi = rpmfiInit(rpmteFI(p), 0); while (rpmfiNext(fi) >= 0) { size_t keylen; - unsigned int keyhash; - baseName = rpmfiBN(fi); - keyhash = rpmStringSetKeyHash(baseNames, baseName); - if (rpmStringSetHasHEntry(baseNames, baseName, keyhash)) + baseNameId = rpmfiBNId(fi); + + if (rpmStringSetHasEntry(baseNames, baseNameId)) continue; - keylen = strlen(baseName); + keylen = rpmstrPoolStrlen(tsmem->pool, baseNameId); + baseName = rpmstrPoolStr(tsmem->pool, baseNameId); if (keylen == 0) keylen++; /* XXX "/" fixup. */ rpmdbExtendIterator(mi, baseName, keylen); - rpmStringSetAddHEntry(baseNames, baseName, keyhash); + rpmStringSetAddEntry(baseNames, baseNameId); } } rpmtsiFree(pi); |