diff options
author | Joey Hess <joey@gnu.kitenet.net> | 2010-03-14 15:21:42 -0400 |
---|---|---|
committer | Joey Hess <joey@gnu.kitenet.net> | 2010-03-14 15:21:42 -0400 |
commit | a5ded6437dc8170fafe170b758c54a44912cb7a8 (patch) | |
tree | 1d643b73d37bdc9e84f785fad7beb87d718d25e8 | |
parent | 223b8efab0a55075bd53d03fe3cb2df07f13d9c1 (diff) | |
download | ikiwiki-a5ded6437dc8170fafe170b758c54a44912cb7a8.tar ikiwiki-a5ded6437dc8170fafe170b758c54a44912cb7a8.tar.gz |
slight optimisation to file_pruned
Precompile the regexp, rather than rebuilding on every call.
-rw-r--r-- | IkiWiki.pm | 8 |
1 files changed, 6 insertions, 2 deletions
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 () { |