From f4e8889f78ea7d2c5655c45c977abf8cef6e79f7 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Wed, 1 Dec 2010 00:10:48 -0500 Subject: refactor resolve_pkg fixes multiple issues with repo/pkg style targets and should cause these queries to run slightly faster. --- expac.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/expac.c b/expac.c index 6582fad..6e4ddba 100644 --- a/expac.c +++ b/expac.c @@ -496,7 +496,7 @@ alpm_list_t *resolve_pkg(alpm_list_t *targets) { } } else { for (t = targets; t; t = alpm_list_next(t)) { - pkgname = alpm_list_getdata(t); + pkgname = reponame = alpm_list_getdata(t); if (strchr(pkgname, '/')) { strsep(&pkgname, "/"); } else { @@ -504,19 +504,21 @@ alpm_list_t *resolve_pkg(alpm_list_t *targets) { } for (r = dblist; r; r = alpm_list_next(r)) { + pmdb_t *repo; pmpkg_t *pkg; - pkg = alpm_db_get_pkg(alpm_list_getdata(r), pkgname); + repo = alpm_list_getdata(r); + if (reponame && strcmp(reponame, alpm_db_get_name(repo)) != 0) { + continue; + } + pkg = alpm_db_get_pkg(repo, pkgname); #ifdef _HAVE_ALPM_FIND_SATISFIER if (!pkg) { - pkg = alpm_find_satisfier(alpm_db_get_pkgcache(alpm_list_getdata(r)), pkgname); + pkg = alpm_find_satisfier(alpm_db_get_pkgcache(repo), pkgname); } #endif - if (reponame && strcmp(reponame, alpm_db_get_name(alpm_list_getdata(r))) != 0) { - continue; - } if (!pkg) { if (verbose) { fprintf(stderr, "error: package `%s' not found\n", pkgname); -- cgit v1.2.3-70-g09d2