From c3ca6b81bcaf38357530305412efc68775d76463 Mon Sep 17 00:00:00 2001 From: Alexey Tourbin Date: Tue, 25 Jan 2011 06:41:24 +0300 Subject: [PATCH] depcache.cc: optimize CheckDep() calls for Now/Install/Candidate versions --- apt/apt-pkg/depcache.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apt/apt-pkg/depcache.cc b/apt/apt-pkg/depcache.cc index c72c2df..20f9987 100644 --- a/apt/apt-pkg/depcache.cc +++ b/apt/apt-pkg/depcache.cc @@ -506,9 +506,19 @@ unsigned char pkgDepCache::DependencyState(DepIterator &D) if (CheckDep(D,NowVersion) == true) State |= DepNow; - if (CheckDep(D,InstallVersion) == true) + + PkgIterator Pkg = D.TargetPkg(); + Version *CurrentVer = Pkg.CurrentVer(); + Version *InstallVer = PkgState[Pkg->ID].InstallVer; + Version *CandidateVer = PkgState[Pkg->ID].CandidateVer; + + if ((InstallVer == CurrentVer && (State & DepNow)) || + CheckDep(D,InstallVersion) == true) State |= DepInstall; - if (CheckDep(D,CandidateVersion) == true) + + if ((CandidateVer == CurrentVer && (State & DepNow)) || + (CandidateVer == InstallVer && (State & DepInstall)) || + CheckDep(D,CandidateVersion) == true) State |= DepCVer; return State;