From c4c786f19bde3247f6fcb95012dfac55787fa4b9 Mon Sep 17 00:00:00 2001 From: Jose Date: Tue, 23 Dec 2025 22:14:22 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor=20loo?= =?UTF-8?q?p=20for=20improved=20readability=20and=20efficiency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This refactoring improves the readability and efficiency of the loop by simplifying the logic and reducing redundant operations. --- tasks/main.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 92a095f..e940b91 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -47,12 +47,14 @@ {{ wol_detected_interfaces | combine({ item: ( - bridge_links.stdout_lines - | select('search', 'master ' ~ item) - | map('regex_replace', '^\\d+: ([^:@]+):.*$', '\\1') - | reject('search', '^(veth|tap|fw)') - | list - ) | first | default('') + [ + line | regex_search('^\\d+: ([a-z0-9@.]+):', '\\1') | first + for line in bridge_links.stdout_lines + if ('master ' ~ item) in line + and not line is search('^\\d+: (veth|tap|fw)') + ] + | first | default('') + ) }) }} loop: "{{ wol_bridges_list }}"