summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2012-10-05 11:38:26 +0300
committerPanu Matilainen <pmatilai@redhat.com>2012-10-05 11:38:26 +0300
commite17bf0449dc54d007b66954170b9d12dad1e74a2 (patch)
treeeb33c76009041604af83c1353fe3964b7efbe00c /lib
parent15f9f2d7f0dd4b41eb87282bf92cc16d5425b2ab (diff)
downloadlibrpm-tizen-e17bf0449dc54d007b66954170b9d12dad1e74a2.tar.gz
librpm-tizen-e17bf0449dc54d007b66954170b9d12dad1e74a2.tar.bz2
librpm-tizen-e17bf0449dc54d007b66954170b9d12dad1e74a2.zip
Use rpmal lookups for already added obsoletions too
- Related to commit bee348b5d101a0ea6039b56c39e8ddc1cfc09a1a, use the newly added obsoletes hash to lookup already added obsoleters. Eliminates the dumb linear lookup and is unsurprisingly a whole lot faster on larger transactions.
Diffstat (limited to 'lib')
-rw-r--r--lib/depends.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/lib/depends.c b/lib/depends.c
index 4fbdb9680..33a5346e9 100644
--- a/lib/depends.c
+++ b/lib/depends.c
@@ -233,30 +233,20 @@ static int addObsoleteErasures(rpmts ts, rpm_color_t tscolor, rpmte p)
}
/*
- * rpmal doesn't (yet) know about obsoletes within the set, so we have
- * no choice but to walk through all the elements. In theory there could
+ * Lookup obsoletions in the added set. In theory there could
* be more than one obsoleting package, but we only care whether this
* has been obsoleted by *something* or not.
*/
-static rpmte checkObsoleted(rpmts ts, rpmds thisds)
+static rpmte checkObsoleted(rpmal addedPackages, rpmds thisds)
{
- rpmtsi pi = rpmtsiInit(ts);
- rpmte p;
- int match = 0;
-
- while ((p = rpmtsiNext(pi, TR_ADDED)) != NULL) {
- rpmds obsoletes = rpmdsInit(rpmteDS(p, RPMTAG_OBSOLETENAME));
+ rpmte p = NULL;
+ rpmte *matches = NULL;
- while (rpmdsNext(obsoletes) >= 0) {
- if (rpmdsCompare(obsoletes, thisds)) {
- match = 1;
- break;
- }
- }
- if (match)
- break;
+ matches = rpmalAllObsoletes(addedPackages, thisds);
+ if (matches) {
+ p = matches[0];
+ free(matches);
}
- rpmtsiFree(pi);
return p;
}
@@ -320,7 +310,7 @@ static int findPos(rpmts ts, rpm_color_t tscolor, rpmte te, int upgrade)
rpmds obsChk = rpmteDS(te, RPMTAG_OBSOLETENAME);
/* If obsoleting package has already been added, skip this. */
- if ((p = checkObsoleted(ts, rpmteDS(te, RPMTAG_NAME)))) {
+ if ((p = checkObsoleted(tsmem->addedPackages, rpmteDS(te, RPMTAG_NAME)))) {
skip = 1;
goto exit;
}