]> git.proxmox.com Git - pve-common.git/commitdiff
INotify: simplify lookup_type_prio
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 4 Oct 2018 11:34:22 +0000 (13:34 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 4 Oct 2018 11:34:22 +0000 (13:34 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/PVE/INotify.pm

index c42f885d65131e6f9a35500f9ff0c1d67e89c892..7a6cfcb112444e927ccd4e9df895e6d916dfa1c8 100644 (file)
@@ -1516,20 +1516,12 @@ NETWORKDOC
 
     my $lookup_type_prio = sub {
        my ($iface, $ifaces) = @_;
 
     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;
            if $n->{type} && $n->{type} ne 'unknown';
 
        return $pri;