From a5ded6437dc8170fafe170b758c54a44912cb7a8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 14 Mar 2010 15:21:42 -0400 Subject: [PATCH] slight optimisation to file_pruned Precompile the regexp, rather than rebuilding on every call. --- IkiWiki.pm | 8 ++++++-- 1 file 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 () { -- 2.26.2