slight optimisation to file_pruned

Precompile the regexp, rather than rebuilding on every call.
master
Joey Hess 2010-03-14 15:21:42 -04:00
parent 223b8efab0
commit a5ded6437d
1 changed files with 6 additions and 2 deletions

View File

@ -1819,6 +1819,7 @@ sub deptype (@) {
return $deptype;
}
my $file_prune_regexp;
sub file_pruned ($;$) {
my $file=shift;
if (@_) {
@ -1833,8 +1834,11 @@ sub file_pruned ($;$) {
return 0 if $file =~ m/$config{include}/;
}
my $regexp='('.join('|', @{$config{wiki_file_prune_regexps}}).')';
return $file =~ m/$regexp/;
if (! defined $file_prune_regexp) {
$file_prune_regexp='('.join('|', @{$config{wiki_file_prune_regexps}}).')';
$file_prune_regexp=qr/$file_prune_regexp/;
}
return $file =~ m/$file_prune_regexp/;
}
sub define_gettext () {