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 > It seems to me as though changing `glob2re` to return qr/$re/, and calling
6 > `memoize(glob2re)` next to the other memoize calls, would be a less
7 > verbose way to do this? --[[smcv]]
9 --------------------------------------------------------------
11 diff --git a/IkiWiki.pm b/IkiWiki.pm
12 index 08a3d78..c187b98 100644
15 @@ -2482,6 +2482,8 @@ sub derel ($$) {
21 sub match_glob ($$;@) {
24 @@ -2489,8 +2491,15 @@ sub match_glob ($$;@) {
26 $glob=derel($glob, $params{location});
28 - my $regexp=IkiWiki::glob2re($glob);
29 - if ($page=~/^$regexp$/i) {
30 + # Instead of converting the glob to a regex every time,
31 + # cache the compiled regex to save time.
32 + if (!exists $glob_cache{$glob}
33 + or !defined $glob_cache{$glob})
35 + my $re=IkiWiki::glob2re($glob);
36 + $glob_cache{$glob} = qr/^$re$/i;
38 + if ($page =~ $glob_cache{$glob}) {
39 if (! IkiWiki::isinternal($page) || $params{internal}) {
40 return IkiWiki::SuccessReason->new("$glob matches $page");
43 --------------------------------------------------------------