mirror of
https://github.com/moparisthebest/pacman
synced 2025-03-01 09:51:50 -05:00
Kill compute_requiredby usage in can_remove_package()
In the can_remove_package function, we don't need to compute the whole requiredby list, we just need to find one member of it that doesn't belong to the targets list. That way we get a small speedup and remove the only usage of alpm_pkg_compute_requiredby in the backend, so that it can be tweaked for frontend usage. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
423820b34c
commit
1b5a851851
@ -438,7 +438,7 @@ pmdepend_t *_alpm_dep_dup(const pmdepend_t *dep)
|
|||||||
static int can_remove_package(pmdb_t *db, pmpkg_t *pkg, alpm_list_t *targets,
|
static int can_remove_package(pmdb_t *db, pmpkg_t *pkg, alpm_list_t *targets,
|
||||||
int include_explicit)
|
int include_explicit)
|
||||||
{
|
{
|
||||||
alpm_list_t *i, *requiredby;
|
alpm_list_t *i, *j;
|
||||||
|
|
||||||
if(_alpm_pkg_find(alpm_pkg_get_name(pkg), targets)) {
|
if(_alpm_pkg_find(alpm_pkg_get_name(pkg), targets)) {
|
||||||
return(0);
|
return(0);
|
||||||
@ -460,15 +460,17 @@ static int can_remove_package(pmdb_t *db, pmpkg_t *pkg, alpm_list_t *targets,
|
|||||||
* if checkdeps detected it would break something */
|
* if checkdeps detected it would break something */
|
||||||
|
|
||||||
/* see if other packages need it */
|
/* see if other packages need it */
|
||||||
requiredby = alpm_pkg_compute_requiredby(pkg);
|
for(i = _alpm_db_get_pkgcache(db); i; i = i->next) {
|
||||||
for(i = requiredby; i; i = i->next) {
|
pmpkg_t *lpkg = i->data;
|
||||||
pmpkg_t *reqpkg = _alpm_db_get_pkgfromcache(db, i->data);
|
for(j = alpm_pkg_get_depends(lpkg); j; j = j->next) {
|
||||||
if(reqpkg && !_alpm_pkg_find(alpm_pkg_get_name(reqpkg), targets)) {
|
if(alpm_depcmp(pkg, j->data)) {
|
||||||
FREELIST(requiredby);
|
if(!_alpm_pkg_find(lpkg->name, targets)) {
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
FREELIST(requiredby);
|
|
||||||
|
|
||||||
/* it's ok to remove */
|
/* it's ok to remove */
|
||||||
return(1);
|
return(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user