From 497226deabdc9c4e797d7da86fe7b0ce6038bf75 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 21 Apr 2010 15:52:58 +0200 Subject: apt/cache.py: Make Cache.req_reinstall_pkgs much faster as well. --- apt/cache.py | 10 ++++++---- debian/changelog | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apt/cache.py b/apt/cache.py index 3b0c5f7e..5d76bca2 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -215,10 +215,12 @@ class Cache(object): def req_reinstall_pkgs(self): """Return the packages not downloadable packages in reqreinst state.""" reqreinst = set() - for pkg in self: - if (not pkg.candidate.downloadable and - (pkg._pkg.inst_state == apt_pkg.INSTSTATE_REINSTREQ or - pkg._pkg.inst_state == apt_pkg.INSTSTATE_HOLD_REINSTREQ)): + get_candidate_ver = self._depcache.get_candidate_ver + states = frozenset((apt_pkg.INSTSTATE_REINSTREQ, + apt_pkg.INSTSTATE_HOLD_REINSTREQ)) + for pkg in self._cache.packages: + cand = get_candidate_ver(pkg) + if cand and not cand.downloadable and pkg.inst_state in states: reqreinst.add(pkg.name) return reqreinst diff --git a/debian/changelog b/debian/changelog index c2c049c3..f3e33d7b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ python-apt (0.7.94.3) UNRELEASED; urgency=low [ Julian Andres Klode ] * apt/cache.py: - Make Cache.get_changes() much (~35x) faster (Closes: #578074). + - Make Cache.req_reinstall_pkgs much faster as well. * apt/package.py: - Decode using utf-8 in installed_files (LP: #407953). - Fix fetch_source() to work when source name = binary name (LP: #552400). -- cgit v1.2.3