1 I've been profiling my IkiWiki to try to improve speed (with many pages makes speed even more important) and I've written a patch to improve the speed of match_glob. This matcher is a good one to improve the speed of, because it gets called so many times.
3 Here's my patch - please consider it! -- [[KathrynAndersen]]
5 --------------------------------------------------------------
7 diff --git a/IkiWiki.pm b/IkiWiki.pm
8 index 08a3d78..c187b98 100644
11 @@ -2482,6 +2482,8 @@ sub derel ($$) {
17 sub match_glob ($$;@) {
20 @@ -2489,8 +2491,15 @@ sub match_glob ($$;@) {
22 $glob=derel($glob, $params{location});
24 - my $regexp=IkiWiki::glob2re($glob);
25 - if ($page=~/^$regexp$/i) {
26 + # Instead of converting the glob to a regex every time,
27 + # cache the compiled regex to save time.
28 + if (!exists $glob_cache{$glob}
29 + or !defined $glob_cache{$glob})
31 + my $re=IkiWiki::glob2re($glob);
32 + $glob_cache{$glob} = qr/^$re$/i;
34 + if ($page =~ $glob_cache{$glob}) {
35 if (! IkiWiki::isinternal($page) || $params{internal}) {
36 return IkiWiki::SuccessReason->new("$glob matches $page");
39 --------------------------------------------------------------