1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-14 05:15:11 -05:00

avoided two calls to db_scan() in checkdeps()

This commit is contained in:
Aurelien Foret 2005-04-20 19:46:53 +00:00
parent b7d584feb6
commit 406f383192

View File

@ -146,26 +146,25 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
* listed in the requiredby field. * listed in the requiredby field.
*/ */
for(i = packages; i; i = i->next) { for(i = packages; i; i = i->next) {
pmpkg_t *tp, *oldpkg; pmpkg_t *tp = i->data;
if(i->data == NULL) { pmpkg_t *oldpkg;
if(tp == NULL) {
continue; continue;
} }
tp = (pmpkg_t *)i->data;
if((oldpkg = db_scan(db, tp->name, INFRQ_DESC | INFRQ_DEPENDS)) == NULL) { if((oldpkg = db_get_pkgfromcache(db, tp->name)) == NULL) {
continue; continue;
} }
for(j = oldpkg->requiredby; j; j = j->next) { for(j = oldpkg->requiredby; j; j = j->next) {
char *ver; char *ver;
pmpkg_t *p; pmpkg_t *p;
found = 0; found = 0;
if((p = db_scan(db, j->data, INFRQ_DESC | INFRQ_DEPENDS)) == NULL) { if((p = db_get_pkgfromcache(db, j->data)) == NULL) {
/* hmmm... package isn't installed.. */ /* hmmm... package isn't installed.. */
continue; continue;
} }
if(pkg_isin(p, packages)) { if(pkg_isin(p, packages)) {
/* this package is also in the upgrade list, so don't worry about it */ /* this package is also in the upgrade list, so don't worry about it */
FREEPKG(p);
continue; continue;
} }
for(k = p->depends; k && !found; k = k->next) { for(k = p->depends; k && !found; k = k->next) {
@ -180,7 +179,6 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
PMList *provides = _alpm_db_whatprovides(db, depend.name); PMList *provides = _alpm_db_whatprovides(db, depend.name);
if(provides == NULL) { if(provides == NULL) {
/* not found */ /* not found */
FREEPKG(p);
continue; continue;
} }
/* we found an installed package that provides depend.name */ /* we found an installed package that provides depend.name */
@ -218,9 +216,7 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
FREE(miss); FREE(miss);
} }
} }
FREEPKG(p);
} }
FREEPKG(oldpkg);
} }
} }
if(op == PM_TRANS_TYPE_ADD || op == PM_TRANS_TYPE_UPGRADE) { if(op == PM_TRANS_TYPE_ADD || op == PM_TRANS_TYPE_UPGRADE) {