diff options
author | Simon McVittie <smcv@ http://smcv.pseudorandom.co.uk/> | 2009-08-25 00:02:27 +0100 |
---|---|---|
committer | Simon McVittie <smcv@ http://smcv.pseudorandom.co.uk/> | 2009-08-25 00:31:24 +0100 |
commit | 275dd5c4ea748261741236a62ad763c775a651c5 (patch) | |
tree | b5ec421f9824f938392a2d157efb55eb9454dacd | |
parent | e4cd168ebedd95585290c97ff42234344bfed46c (diff) | |
download | ikiwiki-275dd5c4ea748261741236a62ad763c775a651c5.tar ikiwiki-275dd5c4ea748261741236a62ad763c775a651c5.tar.gz |
IkiWiki::pagename: memoize results
This relies for its correctness on %config, %hooks and pagetype() not
changing.
-rw-r--r-- | IkiWiki.pm | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm index 35fee1aa7..8a8695768 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -661,9 +661,15 @@ sub pagetype ($) { return; } +my %pagename_cache; + sub pagename ($) { my $file=shift; + if (exists $pagename_cache{$file}) { + return $pagename_cache{$file}; + } + my $type=pagetype($file); my $page=$file; $page=~s/\Q.$type\E*$// @@ -672,6 +678,8 @@ sub pagename ($) { if ($config{indexpages} && $page=~/(.*)\/index$/) { $page=$1; } + + $pagename_cache{$file} = $page; return $page; } |