aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/sidebar.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2010-04-15 22:18:56 -0400
committerJoey Hess <joey@gnu.kitenet.net>2010-04-15 22:18:56 -0400
commitdd64c2a9c0d7a1bfe9d3b89957efe8f045091111 (patch)
treef70ea42f75dfc896d64b1700f78c8dcb2b5714db /IkiWiki/Plugin/sidebar.pm
parent4efc897fdfedeba55a55e82fd4b0145235281883 (diff)
downloadikiwiki-dd64c2a9c0d7a1bfe9d3b89957efe8f045091111.tar
ikiwiki-dd64c2a9c0d7a1bfe9d3b89957efe8f045091111.tar.gz
sidebar plugin optimisations
The pagetemplate hook may be called multiple times, for example when pages are inlined into a page. Sidebars were being calculated each time that happened, only to be thrown away when the final pagetemplate hook was called. Avoid this unnecessary work. Remove stored sidebar content on use to save some memory.
Diffstat (limited to 'IkiWiki/Plugin/sidebar.pm')
-rw-r--r--IkiWiki/Plugin/sidebar.pm9
1 files changed, 4 insertions, 5 deletions
diff --git a/IkiWiki/Plugin/sidebar.pm b/IkiWiki/Plugin/sidebar.pm
index 808f0bed2..0350f2b71 100644
--- a/IkiWiki/Plugin/sidebar.pm
+++ b/IkiWiki/Plugin/sidebar.pm
@@ -60,7 +60,7 @@ my $oldcontent;
sub sidebar_content ($) {
my $page=shift;
- return $pagesidebar{$page} if defined $pagesidebar{$page};
+ return delete $pagesidebar{$page} if defined $pagesidebar{$page};
return if ! exists $pagesidebar{$page} &&
defined $config{global_sidebars} && ! $config{global_sidebars};
@@ -97,11 +97,10 @@ sub sidebar_content ($) {
sub pagetemplate (@) {
my %params=@_;
- my $page=$params{page};
my $template=$params{template};
-
- if ($template->query(name => "sidebar")) {
- my $content=sidebar_content($page);
+ if ($params{destpage} eq $params{page} &&
+ $template->query(name => "sidebar")) {
+ my $content=sidebar_content($params{destpage});
if (defined $content && length $content) {
$template->param(sidebar => $content);
}