From: Joey Hess Date: Sun, 14 Mar 2010 19:21:42 +0000 (-0400) Subject: slight optimisation to file_pruned X-Git-Tag: 3.20100403~160 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a5ded6437dc8170fafe170b758c54a44912cb7a8;p=ikiwiki.git slight optimisation to file_pruned Precompile the regexp, rather than rebuilding on every call. --- diff --git a/IkiWiki.pm b/IkiWiki.pm index ee94ce659..1c2ddbd91 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -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 () {