summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2016-04-08 13:03:05 +0200
committerJulian Andres Klode <jak@debian.org>2016-08-31 13:49:37 +0200
commit43e01d61c2f9872536ff8b879b58ae367d2ec8cb (patch)
tree674e045db04f590550077d6a7d9139d439d29bf2 /apt-pkg
parent90daf43aeb6a911f6511faf5064f5811fd27acb5 (diff)
more explicit MarkRequired algorithm code
Piling everything in a single if statement always made my head wobble, but it hasn't even a benefit as the most common case of a package which isn't installed passes all of the old if and lands in the non-existent else-part of the inner if. So beside a subjective cleanup of what goes on this implementation should also be a bit faster. No change in behavior should be present. Gbp-Dch: Ignore (cherry picked from commit 769e9f3ea1cbe67d3b98e6db6c956abde2384868)
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/depcache.cc51
1 files changed, 32 insertions, 19 deletions
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 01ae66ed2..ee40b879c 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -1847,28 +1847,41 @@ bool pkgDepCache::MarkRequired(InRootSetFunc &userFunc)
bool const follow_suggests = MarkFollowsSuggests();
// do the mark part, this is the core bit of the algorithm
- for(PkgIterator p = PkgBegin(); !p.end(); ++p)
+ for (PkgIterator P = PkgBegin(); !P.end(); ++P)
{
- if(!(PkgState[p->ID].Flags & Flag::Auto) ||
- (p->Flags & Flag::Essential) ||
- (p->Flags & Flag::Important) ||
- userFunc.InRootSet(p) ||
- // be nice even then a required package violates the policy (#583517)
- // and do the full mark process also for required packages
- (p.CurrentVer().end() != true &&
- p.CurrentVer()->Priority == pkgCache::State::Required) ||
- // packages which can't be changed (like holds) can't be garbage
- (IsModeChangeOk(ModeGarbage, p, 0, false) == false))
+ if (P->CurrentVer == 0)
{
- // the package is installed (and set to keep)
- if(PkgState[p->ID].Keep() && !p.CurrentVer().end())
- MarkPackage(p, p.CurrentVer(),
- follow_recommends, follow_suggests);
- // the package is to be installed
- else if(PkgState[p->ID].Install())
- MarkPackage(p, PkgState[p->ID].InstVerIter(*this),
- follow_recommends, follow_suggests);
+ if (PkgState[P->ID].Keep())
+ continue;
+ }
+ else
+ {
+ if (PkgState[P->ID].Delete())
+ continue;
}
+
+ if ((PkgState[P->ID].Flags & Flag::Auto) == 0)
+ ;
+ else if ((P->Flags & Flag::Essential) || (P->Flags & Flag::Important))
+ ;
+ // be nice even then a required package violates the policy (#583517)
+ // and do the full mark process also for required packages
+ else if (P->CurrentVer != 0 && P.CurrentVer()->Priority == pkgCache::State::Required)
+ ;
+ else if (userFunc.InRootSet(P))
+ ;
+ // packages which can't be changed (like holds) can't be garbage
+ else if (IsModeChangeOk(ModeGarbage, P, 0, false) == false)
+ ;
+ else
+ continue;
+
+ if (PkgState[P->ID].Install())
+ MarkPackage(P, PkgState[P->ID].InstVerIter(*this),
+ follow_recommends, follow_suggests);
+ else
+ MarkPackage(P, P.CurrentVer(),
+ follow_recommends, follow_suggests);
}
return true;