From a41d4ba65bc0841a28ea9c8e9fd13f2c4e00ce86 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 4 Feb 2025 09:52:59 +0100 Subject: solver3: Simplify WhyStr() Reuse the generic variable rendering --- apt-pkg/solver3.cc | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'apt-pkg/solver3.cc') diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc index b098d33ba..fce7da0d6 100644 --- a/apt-pkg/solver3.cc +++ b/apt-pkg/solver3.cc @@ -239,22 +239,11 @@ std::string APT::Solver::WhyStr(Var reason) while (not reason.empty()) { - if (auto Pkg = reason.Pkg(cache); not Pkg.end()) - { - if ((*this)[Pkg].decision == Decision::MUSTNOT) - out.push_back(std::string("not ") + Pkg.FullName()); - else - out.push_back(Pkg.FullName()); - reason = (*this)[Pkg].reason; - } - if (auto Ver = reason.Ver(cache); not Ver.end()) - { - if ((*this)[Ver].decision == Decision::MUSTNOT) - out.push_back(std::string("not ") + Ver.ParentPkg().FullName() + "=" + Ver.VerStr()); - else - out.push_back(Ver.ParentPkg().FullName() + "=" + Ver.VerStr()); - reason = (*this)[Ver].reason; - } + if ((*this)[reason].decision == Decision::MUSTNOT) + out.push_back(std::string("not ") + reason.toString(cache)); + else + out.push_back(reason.toString(cache)); + reason = (*this)[reason].reason; } std::string outstr; -- cgit v1.2.3-70-g09d2