From 73f7997dbf6b53cd843d98c9b6a087bcab0e79ac Mon Sep 17 00:00:00 2001 From: eleksir Date: Sat, 15 Oct 2016 14:52:21 +0300 Subject: [PATCH] micro optimization for big lists --- notifications.pl | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/notifications.pl b/notifications.pl index 126d589..431b9ca 100644 --- a/notifications.pl +++ b/notifications.pl @@ -25,7 +25,7 @@ my $help = 'Usage: /notify show - shows whitelists and their statuses '; -register($script_name, '0.8.1', 'Sends *nix desktop notifications', \&freehooks); +register($script_name, '0.8.2', 'Sends *nix desktop notifications', \&freehooks); HexChat::print("$script_name loaded\n"); my @hooks; @@ -59,7 +59,11 @@ sub hookfn { foreach (@nicklist) { next unless(defined($_)); next if($_ eq ''); - $flag = 1 if ($_ eq $nick); + + if ($_ eq $nick) { + $flag = 1; + last; + } } } @@ -69,7 +73,11 @@ sub hookfn { foreach (@chanlist) { next unless(defined($_)); next if($_ eq ''); - $flag = 1 if ($_ eq $channel); + + if ($_ eq $channel) { + $flag = 1; + last; + } } } @@ -79,7 +87,11 @@ sub hookfn { foreach (@netlist) { next unless(defined($_)); next if($_ eq ''); - $flag = 1 if ($_ eq $network); + + if ($_ eq $network){ + $flag = 1; + last; + } } }