apt_facts - Fix cache related performance regression (#60511)
* apt_facts - Fix cache related performance regression * Another minor performance improvement
This commit is contained in:
parent
b07f96c31d
commit
0f35e4b7b9
2 changed files with 6 additions and 2 deletions
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- apt_facts - fix performance regression when getting facts about apt packages (https://github.com/ansible/ansible/issues/60450)
|
|
@ -192,7 +192,7 @@ class APT(LibMgr):
|
|||
|
||||
@property
|
||||
def pkg_cache(self):
|
||||
if self._cache:
|
||||
if self._cache is not None:
|
||||
return self._cache
|
||||
|
||||
self._cache = self._lib.Cache()
|
||||
|
@ -209,7 +209,9 @@ class APT(LibMgr):
|
|||
return we_have_lib
|
||||
|
||||
def list_installed(self):
|
||||
return [pk for pk in self.pkg_cache.keys() if self.pkg_cache[pk].is_installed]
|
||||
# Store the cache to avoid running pkg_cache() for each item in the comprehension, which is very slow
|
||||
cache = self.pkg_cache
|
||||
return [pk for pk in cache.keys() if cache[pk].is_installed]
|
||||
|
||||
def get_package_details(self, package):
|
||||
ac_pkg = self.pkg_cache[package].installed
|
||||
|
|
Loading…
Reference in a new issue