IkiWiki::pagename: memoize results

This relies for its correctness on %config, %hooks and pagetype() not
changing.
master
Simon McVittie 2009-08-25 00:02:27 +01:00
parent e4cd168ebe
commit 275dd5c4ea
1 changed files with 8 additions and 0 deletions

View File

@ -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;
}