From: Fabian Grünbichler Date: Wed, 7 Jun 2023 09:49:07 +0000 (+0200) Subject: api2: network: improve code readability X-Git-Url: https://git.proxmox.com/?p=pve-manager.git;a=commitdiff_plain;h=8961f9f7801628f766a6135c466091a0f254e3b0 api2: network: improve code readability nested conditionals stretching over multiple lines are always a bit hard to untangle, so let's make it explicit: 1. is the interface a bridge 2. if it is, are we looking for one? 3. is it something else that we are looking for? Signed-off-by: Fabian Grünbichler --- diff --git a/PVE/API2/Network.pm b/PVE/API2/Network.pm index 558d78a9..00d964a7 100644 --- a/PVE/API2/Network.pm +++ b/PVE/API2/Network.pm @@ -247,9 +247,9 @@ __PACKAGE__->register_method({ for my $k (sort keys $ifaces->%*) { my $type = $ifaces->{$k}->{type}; - my $match = ($tfilter eq $type) || ( - ($tfilter =~ /^any(_local)?_bridge$/) && - ($type eq 'bridge' || $type eq 'OVSBridge')); + my $is_bridge = $type eq 'bridge' || $type eq 'OVSBridge'; + my $bridge_match = $is_bridge && $tfilter =~ /^any(_local)?_bridge$/; + my $match = $tfilter eq $type || $bridge_match; delete $ifaces->{$k} if !$match; }