IkiWiki::pagename: memoize results
This relies for its correctness on %config, %hooks and pagetype() not changing.master
parent
e4cd168ebe
commit
275dd5c4ea
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue