From 3c4551bbdae483d37b985b2c690d77372fb50e89 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 3 Feb 2025 16:03:17 +0100 Subject: solver3: Simplify work ordering Moving the optional != b.optional comparison ahead of the group one allows us to get a better behavior; and now we avoid the nested if. Also remove the special cases that ordered based on the reason of the work item, these have been superseded by groups a while ago. --- apt-pkg/solver3.cc | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc index 42e6fedce..15d55be38 100644 --- a/apt-pkg/solver3.cc +++ b/apt-pkg/solver3.cc @@ -196,22 +196,12 @@ bool APT::Solver::Work::operator<(APT::Solver::Work const &b) const { if ((not optional && size < 2) != (not b.optional && b.size < 2)) return not b.optional && b.size < 2; - if (group != b.group) - return group > b.group; - if (optional && b.optional) - { - if ((size < 2) != (b.size < 2)) - return b.size < 2; - if (reason.empty() != b.reason.empty()) - return reason.empty(); - } - // An optional item is less important than a required one. if (optional != b.optional) return optional; - // We enqueue common dependencies at the package level to avoid choosing versions, so let's solve package items first, - // this improves the implication graph as it now tells you that common dependencies were installed by the package. - if (reason.Pkg() != b.reason.Pkg()) - return reason.Pkg() == 0; + if (group != b.group) + return group > b.group; + if ((size < 2) != (b.size < 2)) + return b.size < 2; return false; } -- cgit v1.2.3-70-g09d2