From 0c0bcf7cdc7f729b5594b468fd7b0c9418465a29 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 4 Oct 2018 13:34:22 +0200 Subject: [PATCH] INotify: simplify lookup_type_prio Signed-off-by: Wolfgang Bumiller --- src/PVE/INotify.pm | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm index c42f885..7a6cfcb 100644 --- a/src/PVE/INotify.pm +++ b/src/PVE/INotify.pm @@ -1516,20 +1516,12 @@ NETWORKDOC my $lookup_type_prio = sub { my ($iface, $ifaces) = @_; - my $child = 0; - my $n = undef; - my $i=1; - for my $childiface (split(/(\.|:)/, $iface)) { - if ($i > 1) { - $child++; - } else { - $n = $ifaces->{$childiface}; - } - $i++; - } + my ($rootiface, @rest) = split(/[.:]/, $iface); + my $childlevel = scalar(@rest); + my $n = $ifaces->{$rootiface}; - my $pri = $if_type_hash->{$n->{type}} + $child + my $pri = $if_type_hash->{$n->{type}} + $childlevel if $n->{type} && $n->{type} ne 'unknown'; return $pri; -- 2.39.2