mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-23 00:08:50 -05:00
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 <dan@archlinux.org>
This commit is contained in:
parent
7f480ccc0d
commit
c40fc6b80d
@ -339,11 +339,10 @@ static void find_requiredby(pmpkg_t *pkg, pmdb_t *db, alpm_list_t **reqs)
|
|||||||
{
|
{
|
||||||
const alpm_list_t *i;
|
const alpm_list_t *i;
|
||||||
for(i = _alpm_db_get_pkgcache(db); i; i = i->next) {
|
for(i = _alpm_db_get_pkgcache(db); i; i = i->next) {
|
||||||
if(!i->data) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
pmpkg_t *cachepkg = i->data;
|
pmpkg_t *cachepkg = i->data;
|
||||||
if(_alpm_dep_edge(cachepkg, pkg)) {
|
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;
|
const char *cachepkgname = cachepkg->name;
|
||||||
if(alpm_list_find_str(*reqs, cachepkgname) == NULL) {
|
if(alpm_list_find_str(*reqs, cachepkgname) == NULL) {
|
||||||
*reqs = alpm_list_add(*reqs, strdup(cachepkgname));
|
*reqs = alpm_list_add(*reqs, strdup(cachepkgname));
|
||||||
@ -351,6 +350,7 @@ static void find_requiredby(pmpkg_t *pkg, pmdb_t *db, alpm_list_t **reqs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Compute the packages requiring a given package.
|
* @brief Compute the packages requiring a given package.
|
||||||
@ -377,8 +377,8 @@ alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(pmpkg_t *pkg)
|
|||||||
for(i = handle->dbs_sync; i; i = i->next) {
|
for(i = handle->dbs_sync; i; i = i->next) {
|
||||||
db = i->data;
|
db = i->data;
|
||||||
find_requiredby(pkg, db, &reqs);
|
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);
|
return(reqs);
|
||||||
|
Loading…
Reference in New Issue
Block a user