summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2016-04-08 13:03:05 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2016-06-30 18:57:49 +0200
commit769e9f3ea1cbe67d3b98e6db6c956abde2384868 (patch)
tree396d928a0a42c500d3ebc17550bde4c98b52b774 /apt-pkg
parentb8242321065c0f0e498ffcf6ba92675a19011dd4 (diff)
downloadapt-769e9f3ea1cbe67d3b98e6db6c956abde2384868.tar.gz
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
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;