pacman: speed up deptest

Try and find an exact match via pkgcache before iterating the entire
localdb.

Gives a noticeable speed up for exact matches e.g. `pacman -T zlib`

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
morganamilo 2019-09-08 22:45:29 +01:00 committed by Allan McRae
parent f2442bc2e9
commit 8f89e509d2

View File

@ -32,11 +32,13 @@ int pacman_deptest(alpm_list_t *targets)
alpm_list_t *i;
alpm_list_t *deps = NULL;
alpm_db_t *localdb = alpm_get_localdb(config->handle);
alpm_list_t *pkgcache = alpm_db_get_pkgcache(localdb);
for(i = targets; i; i = alpm_list_next(i)) {
char *target = i->data;
if(!alpm_find_satisfier(alpm_db_get_pkgcache(localdb), target)) {
if(!alpm_db_get_pkg(localdb, target) &&
!alpm_find_satisfier(pkgcache, target)) {
deps = alpm_list_add(deps, target);
}
}