1 [[!meta author="""http://kerravonsen.dreamwidth.org/"""]]
3 [[!meta authorurl="""http://kerravonsen.dreamwidth.org/"""]]
5 [[!meta title="""change to todo/Improving_the_efficiency_of_match__95__glob on ikiwiki"""]]
7 [[!meta permalink="http://ikiwiki.info/recentchanges/#change-171c429f829aac53cb449e3bb574d2a1669e025e"]]
9 <div id="change-171c429f829aac53cb449e3bb574d2a1669e025e" class="metadata">
10 <span class="desc"><br />Changed pages:</span>
11 <span class="pagelinks">
13 <a href="http://git.ikiwiki.info/?p=ikiwiki;a=blobdiff;f=doc/todo/Improving_the_efficiency_of_match__95__glob.mdwn;h=8f70f1dde4bbe7fd7b66807c36e6f4d7fd0b08b0;hp=0000000000000000000000000000000000000000;hb=171c429f829aac53cb449e3bb574d2a1669e025e;hpb=9c8f86ee9c59035c9462d2c69c7b89d0c9dbc3c2" title="diff" rel="nofollow">[[diff|wikiicons/diff.png]]</a><a href="http://ikiwiki.info/ikiwiki.cgi?page=todo%2FImproving_the_efficiency_of_match__95__glob&do=goto" rel="nofollow">todo/Improving the efficiency of match_glob</a>
17 <span class="desc"><br />Changed by:</span>
18 <span class="committer">
20 <a href="http://kerravonsen.dreamwidth.org/" rel="nofollow">kerravonsen [dreamwidth.org]</a>
23 <span class="desc"><br />Commit type:</span>
24 <span class="committype">web</span>
25 <span class="desc"><br />Date:</span>
26 <span class="changedate"><span class="relativedate" title="Tue, 09 Nov 2010 20:53:10 -0400">20:53:10 11/09/10</span></span>
27 <span class="desc"><br /></span>
31 <a href="http://ikiwiki.info/ikiwiki.cgi?rev=171c429f829aac53cb449e3bb574d2a1669e025e&do=revert" title="revert" rel="nofollow">[[revert|wikiicons/revert.png]]</a>
34 <div class="changelog">
37 make match_glob faster - patch!<br />
44 diff --git a/doc/todo/Improving_the_efficiency_of_match__95__glob.mdwn b/doc/todo/Improving_the_efficiency_of_match__95__glob.mdwn
46 index 0000000..8f70f1d
48 +++ b/doc/todo/Improving_the_efficiency_of_match__95__glob.mdwn
50 +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.
52 +Here's my patch - please consider it! -- [[KathrynAndersen]]
54 +--------------------------------------------------------------
56 +diff --git a/IkiWiki.pm b/IkiWiki.pm
57 +index 08a3d78..c187b98 100644
60 +@@ -2482,6 +2482,8 @@ sub derel ($$) {
66 + sub match_glob ($$;@) {
69 +@@ -2489,8 +2491,15 @@ sub match_glob ($$;@) {
71 + $glob=derel($glob, $params{location});
73 +- my $regexp=IkiWiki::glob2re($glob);
74 +- if ($page=~/^$regexp$/i) {
75 ++ # Instead of converting the glob to a regex every time,
76 ++ # cache the compiled regex to save time.
77 ++ if (!exists $glob_cache{$glob}
78 ++ or !defined $glob_cache{$glob})
80 ++ my $re=IkiWiki::glob2re($glob);
81 ++ $glob_cache{$glob} = qr/^$re$/i;
83 ++ if ($page =~ $glob_cache{$glob}) {
84 + if (! IkiWiki::isinternal($page) || $params{internal}) {
85 + return IkiWiki::SuccessReason->new("$glob matches $page");
88 +--------------------------------------------------------------
93 <!-- 171c429f829aac53cb449e3bb574d2a1669e025e -->