summaryrefslogtreecommitdiff
path: root/apt-pkg/solver3.h
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2025-02-03 19:22:52 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2025-02-07 20:59:43 +0100
commit5b7af08e4b23f00fc1de4dfe4178d867a560553d (patch)
tree1da91ae594fcb5e3bb200f133958e0e2bf9b3540 /apt-pkg/solver3.h
parentae2fc9b5121e4a253d1f81fcf14bcd2afd59538c (diff)
solver3: Cache calls to policy
It's a bit silly otherwise.
Diffstat (limited to 'apt-pkg/solver3.h')
-rw-r--r--apt-pkg/solver3.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/apt-pkg/solver3.h b/apt-pkg/solver3.h
index 548c3b777..2868616de 100644
--- a/apt-pkg/solver3.h
+++ b/apt-pkg/solver3.h
@@ -114,6 +114,20 @@ class Solver
mutable std::vector<char> pkgObsolete;
bool Obsolete(pkgCache::PkgIterator pkg) const;
bool ObsoletedByNewerSourceVersion(pkgCache::VerIterator cand) const;
+ mutable std::vector<short> priorities;
+ short GetPriority(pkgCache::VerIterator ver) const
+ {
+ if (priorities[ver->ID] == 0)
+ priorities[ver->ID] = policy.GetPriority(ver);
+ return priorities[ver->ID];
+ }
+ mutable std::vector<pkgCache::VerIterator> candidates;
+ pkgCache::VerIterator GetCandidateVer(pkgCache::PkgIterator pkg) const
+ {
+ if (candidates[pkg->ID].end())
+ candidates[pkg->ID] = policy.GetCandidateVer(pkg);
+ return candidates[pkg->ID];
+ }
// \brief Heap of the remaining work.
//