From 2a076dc6a0b210dac4292490f96f54b654a52069 Mon Sep 17 00:00:00 2001 From: kewl fft Date: Sat, 8 Jul 2023 18:51:35 +0100 Subject: [PATCH] optimize check_packages lists construction --- plugins/modules/aur.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/plugins/modules/aur.py b/plugins/modules/aur.py index a391b65..cf1a8fb 100644 --- a/plugins/modules/aur.py +++ b/plugins/modules/aur.py @@ -138,18 +138,8 @@ def check_packages(module, packages): """ Inform the user what would change if the module were run """ - would_be_changed = [] - diff = { - 'before': '', - 'after': '', - } - - for package in packages: - installed = package_installed(module, package) - if not installed: - would_be_changed.append(package) - if module._diff: - diff['after'] += package + "\n" + would_be_changed = [package for package in packages if not package_installed(module, package)] + diff = {'before': '', 'after': '\n'.join(package for package in would_be_changed if module._diff)} if would_be_changed: status = True