From abd1ef84df5e2660ad942275f410fd22f9b64903 Mon Sep 17 00:00:00 2001 From: Gilles Darold Date: Fri, 8 Mar 2019 09:49:26 +0100 Subject: [PATCH] Try to fix performances issue in URL exclusion. --- SquidAnalyzer.pm | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/SquidAnalyzer.pm b/SquidAnalyzer.pm index 0087eb0..bd54570 100644 --- a/SquidAnalyzer.pm +++ b/SquidAnalyzer.pm @@ -1095,13 +1095,11 @@ sub check_exclusions # check for URL exclusion if (exists $self->{Exclude}{uris} && $url) { - return 1 if (grep(/^$url$/i, @{ $self->{UrlExcludeCache} })); - foreach my $e (@{$self->{Exclude}{uris}}) { - if ($url =~ m#^$e$#i) { - push(@{ $self->{UrlExcludeCache} }, $url); - return 1; - } + if (exists $self->{UrlExcludeCache}{$url}) { + %{ $self->{UrlExcludeCache} } = () if (scalar keys %{ $self->{UrlExcludeCache} } > 10000); + return 1; } + map { return 1 if ($url =~ m#^\Q$_\E$#i); } @{$self->{Exclude}{uris}}; } return 0; @@ -1697,7 +1695,7 @@ sub _init %{$self->{UrlAliasCache}} = (); @{$self->{UserExcludeCache}} = (); @{$self->{ClientExcludeCache}} = (); - @{$self->{UrlExcludeCache}} = (); + %{$self->{UrlExcludeCache}} = (); @{$self->{UserIncludeCache}} = (); @{$self->{ClientIncludeCache}} = (); $self->{has_network_alias} = scalar keys %{$self->{NetworkAlias}};