Hi,

the code in checkInstDeps calls checkDS for matched dependencies,
which in turn loops over all dependencies. That's actually not really
needed, as we already know which index to use.

The attached patch makes checkInstDeps directly call unsatisfiedDepend
which the right ds, which makes the code simpler and a tiny bit faster.

Cheers,
  Michael.

-- 
Michael Schroeder                                   m...@suse.de
SUSE LINUX Products GmbH,  GF Jeff Hawn, HRB 16746 AG Nuernberg
main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);}
>From 5b29f64744d01952a77ff6899ba295ff7608093b Mon Sep 17 00:00:00 2001
From: Michael Schroeder <m...@suse.de>
Date: Wed, 13 Aug 2014 12:34:37 +0200
Subject: [PATCH] Use IteratorFileNum in checkInstDeps

The code used to loop over all dependencies instead of using
the information from the database.
---
 lib/depends.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/depends.c b/lib/depends.c
index e871018..bff4342 100644
--- a/lib/depends.c
+++ b/lib/depends.c
@@ -687,7 +687,7 @@ exit:
 /* Check a dependency set for problems */
 static void checkDS(rpmts ts, depCache dcache, rpmte te,
 		const char * pkgNEVRA, rpmds ds,
-		const char * depName, rpm_color_t tscolor)
+		rpm_color_t tscolor)
 {
     rpm_color_t dscolor;
     /* require-problems are unsatisfied, others appear "satisfied" */
@@ -695,10 +695,6 @@ static void checkDS(rpmts ts, depCache dcache, rpmte te,
 
     ds = rpmdsInit(ds);
     while (rpmdsNext(ds) >= 0) {
-	/* Filter out dependencies that came along for the ride. */
-	if (depName != NULL && !rstreq(depName, rpmdsN(ds)))
-	    continue;
-
 	/* Ignore colored dependencies not in our rainbow. */
 	dscolor = rpmdsColor(ds);
 	if (tscolor && dscolor && !(tscolor & dscolor))
@@ -709,13 +705,15 @@ static void checkDS(rpmts ts, depCache dcache, rpmte te,
     }
 }
 
-/* Check a given dependency type against installed packages */
+/* Check a given dependency against installed packages */
 static void checkInstDeps(rpmts ts, depCache dcache, rpmte te,
 			  rpmTag depTag, const char *dep)
 {
     Header h;
     rpmdbMatchIterator mi = rpmtsPrunedIterator(ts, depTag, dep, 1);
     rpmstrPool pool = rpmtsPool(ts);
+    /* require-problems are unsatisfied, others appear "satisfied" */
+    int is_problem = (depTag == RPMTAG_REQUIRENAME);
 
     while ((h = rpmdbNextIterator(mi)) != NULL) {
 	char * pkgNEVRA;
@@ -730,8 +728,10 @@ static void checkInstDeps(rpmts ts, depCache dcache, rpmte te,
 
 	pkgNEVRA = headerGetAsString(h, RPMTAG_NEVRA);
 	ds = rpmdsNewPool(pool, h, depTag, 0);
+	rpmdsSetIx(ds, rpmdbGetIteratorFileNum(mi));
 
-	checkDS(ts, dcache, te, pkgNEVRA, ds, dep, 0);
+	if (unsatisfiedDepend(ts, dcache, ds) == is_problem)
+	    rpmteAddDepProblem(te, pkgNEVRA, ds, NULL);
 
 	rpmdsFree(ds);
 	free(pkgNEVRA);
@@ -829,11 +829,11 @@ int rpmtsCheck(rpmts ts)
 		rpmteNEVR(p), rpmteA(p), rpmteO(p), rpmteColor(p));
 
 	checkDS(ts, dcache, p, rpmteNEVRA(p), rpmteDS(p, RPMTAG_REQUIRENAME),
-		NULL, tscolor);
+		tscolor);
 	checkDS(ts, dcache, p, rpmteNEVRA(p), rpmteDS(p, RPMTAG_CONFLICTNAME),
-		NULL, tscolor);
+		tscolor);
 	checkDS(ts, dcache, p, rpmteNEVRA(p), rpmteDS(p, RPMTAG_OBSOLETENAME),
-		NULL, tscolor);
+		tscolor);
 
 	/* Check provides against conflicts in installed packages. */
 	while (rpmdsNext(provides) >= 0) {
-- 
1.8.1.4

_______________________________________________
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint

Reply via email to