summaryrefslogtreecommitdiff
path: root/lib/rpmps.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2010-03-26 12:23:47 +0200
committerPanu Matilainen <pmatilai@redhat.com>2010-03-26 12:47:18 +0200
commita6bf388ab32f388147084e0f9936ed6567ada776 (patch)
treefe46ddf288cebdc470acade95c5991d2c06a5231 /lib/rpmps.c
parent0aba719592a1dd6532a1e70e9defbad5e62fc1ed (diff)
downloadrpm-a6bf388ab32f388147084e0f9936ed6567ada776.tar.gz
Filter out duplicate problems when adding to element problem sets
- Problems associated with a transaction element are necessarily unique to that element, so when filtered there we don't have to worry about skipping dupes elsewhere like in merged sets. This can actually lead to apparent duplicates in the current problem report output (eg in cases where multiple packages provide the same dependency which would be removed, like multilib packages), but this is only an artifact of they way the problems are currently printed out. - While this is still a dumb linear search, it can be several seconds faster than the previous filtering in rpmpsPrint(), which is now just a dumb convenience function.
Diffstat (limited to 'lib/rpmps.c')
-rw-r--r--lib/rpmps.c40
1 files changed, 10 insertions, 30 deletions
diff --git a/lib/rpmps.c b/lib/rpmps.c
index bdc2ba4fa..7f089af77 100644
--- a/lib/rpmps.c
+++ b/lib/rpmps.c
@@ -194,35 +194,15 @@ int rpmpsMerge(rpmps dest, rpmps src)
void rpmpsPrint(FILE *fp, rpmps ps)
{
- char * msg = NULL;
- rpmpsi psi = NULL;
- int i;
-
- if (ps == NULL || ps->probs == NULL || ps->numProblems <= 0)
- return;
-
- if (fp == NULL)
- fp = stderr;
-
- psi = rpmpsInitIterator(ps);
- while ((i = rpmpsNextIterator(psi)) >= 0) {
- int j;
- rpmProblem p = rpmpsGetProblem(psi);
-
- rpmpsi psif = rpmpsInitIterator(ps);
- /* Filter already displayed problems. */
- while ((j = rpmpsNextIterator(psif)) < i) {
- if (rpmProblemCompare(p, rpmpsGetProblem(psif)) == 0)
- break;
- }
- rpmpsFreeIterator(psif);
- if (j < i)
- continue;
-
- msg = rpmProblemString(p);
- fprintf(fp, "\t%s\n", msg);
- msg = _free(msg);
-
+ rpmProblem p;
+ rpmpsi psi = rpmpsInitIterator(ps);
+ FILE *f = (fp != NULL) ? fp : stderr;
+
+ while ((p = rpmpsiNext(psi))) {
+ char *msg = rpmProblemString(p);
+ fprintf(f, "\t%s\n", msg);
+ free(msg);
}
- psi = rpmpsFreeIterator(psi);
+ rpmpsFreeIterator(psi);
}
+