From 7d84e1f830727ca5008566113e7dfd35df049bd6 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 31 Jan 2026 22:33:40 +0100 Subject: solver3: Fix off-by-one missing optimization We were trying to compare the dependencies in the first version with the dependencies in later version, but our loop started at the first version as well due to an oversight in the use of the increment operator. Change the increment from postfix to prefix such that we start iterating with the 2nd version in the list only. This should yield minute performance optimizations: before: 12: 17.80% 0.00% apt libapt-pkg.so.7.0.0 [.] EDSP::ResolveExternal(char const*, pkgDepCache&, unsigned int, OpProgress*) 14: --17.80%--EDSP::ResolveExternal(char const*, pkgDepCache&, unsigned int, OpProgress*) 20: | | |--6.34%--APT::Solver::DependencySolver::RegisterCommonDependencies(pkgCache::PkgIterator) 44: | | --0.85%--APT::Solver::DependencySolver::RegisterCommonDependencies(pkgCache::PkgIterator) after: 12: 16.98% 0.00% apt libapt-pkg.so.7.0.0 [.] EDSP::ResolveExternal(char const*, pkgDepCache&, unsigned int, OpProgress*) 14: --16.98%--EDSP::ResolveExternal(char const*, pkgDepCache&, unsigned int, OpProgress*) 20: | | |--5.65%--APT::Solver::DependencySolver::RegisterCommonDependencies(pkgCache::PkgIterator) 42: | | --0.70%--APT::Solver::DependencySolver::RegisterCommonDependencies(pkgCache::PkgIterator) --- apt-pkg/solver3.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc index ed2382432..2727c3a1d 100644 --- a/apt-pkg/solver3.cc +++ b/apt-pkg/solver3.cc @@ -1008,7 +1008,7 @@ void DependencySolver::RegisterCommonDependencies(pkgCache::PkgIterator Pkg) dep.GlobOr(start, end); // advances dep bool allHaveDep = true; - for (auto ver = Pkg.VersionList()++; allHaveDep && not ver.end(); ver++) + for (auto ver = ++Pkg.VersionList(); allHaveDep && not ver.end(); ver++) { bool haveDep = false; for (auto otherDep = ver.DependsList(); not haveDep && not otherDep.end();) -- cgit v1.2.3-70-g09d2