Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
libpkg: Micro-optimize upgrade candidate checking
Mark Johnston committed 8 months ago
commit 93e6ca0c51dd8778533bfbe9b4575d281baf4365
parent 7351237
1 file changed +8 -17
modified libpkg/pkg_jobs.c
@@ -1467,30 +1467,21 @@ is_upgrade_candidate(struct pkg_jobs *j, struct pkg *pkg)
	if (pkg->digest == NULL)
		return (true);

+
	/* Does a remote repo have a different version of this package? */
	it = pkgdb_repo_query2(j->db, pkg->uid, MATCH_INTERNAL, j->reponames);
	if (it != NULL) {
-
		/*
-
		 * If we have the same package in a remote repo, it is not an
-
		 * installation candidate
-
		 */
-
		int npkg = 0;
-

		while (pkgdb_it_next(it, &p, PKG_LOAD_BASIC) == EPKG_OK) {
-
			/*
-
			 * Check package with the same uid and explore whether digest
-
			 * has been changed
-
			 */
-
			if (!STREQ(p->digest, pkg->digest))
-
				npkg ++;
-

+
			if (!STREQ(p->digest, pkg->digest)) {
+
				/* Found an upgrade candidate. */
+
				pkg_free(p);
+
				pkgdb_it_free(it);
+
				return (true);
+
			}
			pkg_free(p);
			p = NULL;
		}
-

		pkgdb_it_free(it);
-

-
		if (npkg == 0)
-
			return (false);
+
		return (false);
	}

	return (true);