diff options
| author | Julian Andres Klode <julian.klode@canonical.com> | 2025-02-03 16:03:17 +0100 |
|---|---|---|
| committer | Julian Andres Klode <julian.klode@canonical.com> | 2025-02-07 20:59:43 +0100 |
| commit | 3c4551bbdae483d37b985b2c690d77372fb50e89 (patch) | |
| tree | 27201eaaf538bca4d76d67b3076174fd5970d37e | |
| parent | 52d0baba388a21205b323153a0d83dc6ae75bbf0 (diff) | |
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.
| -rw-r--r-- | apt-pkg/solver3.cc | 18 |
1 files 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; } |
