array_intersect: followup: early exit if first empty intersection found
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 23 Jul 2019 07:04:00 +0000 (09:04 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 23 Jul 2019 07:04:22 +0000 (09:04 +0200)
no point in trying more

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/Tools.pm

index 9b5614f..a9addcd 100644 (file)
@@ -1677,6 +1677,7 @@ sub array_intersect {
        foreach my $element (keys %count) {
            push @$return_arr, $element if $count{$element} > 1;
        }
+       last if scalar(@$return_arr) == 0; # empty intersection, early exit
     }
 
     return $return_arr;