summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormorganamilo <morganamilo@gmail.com>2019-09-08 23:45:28 +0200
committerAllan McRae <allan@archlinux.org>2019-10-07 06:21:08 +0200
commitf2442bc2e9d41a68b9965c272794600836c36b8b (patch)
tree50374b0f389159a5a2bcef25bb7858e5c9045e53
parent0a295f3f396b990e03ab8faec37566de85c99fec (diff)
downloadpacman-f2442bc2e9d41a68b9965c272794600836c36b8b.tar.gz
pacman-f2442bc2e9d41a68b9965c272794600836c36b8b.tar.xz
libalpm: short circuit alpm_find_dbs_satisfier
when a satisfying package is already installed, we always pick it instead of prompting the user. So we can return that package as soon as we find it, instead of waiting until we've iterated through all the databases. Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r--lib/libalpm/deps.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 322c4e7e..f69f24ad 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -719,20 +719,19 @@ static alpm_pkg_t *resolvedep(alpm_handle_t *handle, alpm_depend_t *dep,
}
_alpm_log(handle, ALPM_LOG_DEBUG, "provider found (%s provides %s)\n",
pkg->name, dep->name);
+
+ /* provide is already installed so return early instead of prompting later */
+ if(_alpm_db_get_pkgfromcache(handle->db_local, pkg->name)) {
+ alpm_list_free(providers);
+ return pkg;
+ }
+
providers = alpm_list_add(providers, pkg);
/* keep looking for other providers in the all dbs */
}
}
}
- /* first check if one provider is already installed locally */
- for(i = providers; i; i = i->next) {
- alpm_pkg_t *pkg = i->data;
- if(_alpm_db_get_pkgfromcache(handle->db_local, pkg->name)) {
- alpm_list_free(providers);
- return pkg;
- }
- }
count = alpm_list_count(providers);
if(count >= 1) {
alpm_question_select_provider_t question = {