From c40fc6b80d4a97e3333afab6d2ce8290aaa29c46 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 25 Mar 2011 15:34:39 -0500 Subject: Rework find_requiredby() to not use _alpm_dep_edge() And move the sort after the final loop; we don't need to sort once for each database we look at. Signed-off-by: Dan McGee --- lib/libalpm/package.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/libalpm/package.c') diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 18d77d65..adb1ce9e 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -339,14 +339,14 @@ static void find_requiredby(pmpkg_t *pkg, pmdb_t *db, alpm_list_t **reqs) { const alpm_list_t *i; for(i = _alpm_db_get_pkgcache(db); i; i = i->next) { - if(!i->data) { - continue; - } pmpkg_t *cachepkg = i->data; - if(_alpm_dep_edge(cachepkg, pkg)) { - const char *cachepkgname = cachepkg->name; - if(alpm_list_find_str(*reqs, cachepkgname) == NULL) { - *reqs = alpm_list_add(*reqs, strdup(cachepkgname)); + alpm_list_t *i; + for(i = alpm_pkg_get_depends(cachepkg); i; i = i->next) { + if(_alpm_depcmp(pkg, i->data)) { + const char *cachepkgname = cachepkg->name; + if(alpm_list_find_str(*reqs, cachepkgname) == NULL) { + *reqs = alpm_list_add(*reqs, strdup(cachepkgname)); + } } } } @@ -377,8 +377,8 @@ alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(pmpkg_t *pkg) for(i = handle->dbs_sync; i; i = i->next) { db = i->data; find_requiredby(pkg, db, &reqs); - reqs = alpm_list_msort(reqs, alpm_list_count(reqs), _alpm_str_cmp); } + reqs = alpm_list_msort(reqs, alpm_list_count(reqs), _alpm_str_cmp); } } return(reqs); -- cgit v1.2.3-24-g4f1b