From 50faf0b151e08887b686e88d525b3b3e3b5379e5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 9 Jan 2008 02:30:46 -0500 Subject: Call preprocessor hooks in void context during the scan pass. This allows the hook to determine if it's just scanning, and avoid expensive operations. --- IkiWiki.pm | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index b0ac8bbb4..d001760a2 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -723,12 +723,25 @@ sub preprocess ($$$;$$) { #{{{ $command, $page, $preprocessing{$page}). "]]"; } - my $ret=$hooks{preprocess}{$command}{call}->( - @params, - page => $page, - destpage => $destpage, - preview => $preprocess_preview, - ); + my $ret; + if (! $scan) { + $ret=$hooks{preprocess}{$command}{call}->( + @params, + page => $page, + destpage => $destpage, + preview => $preprocess_preview, + ); + } + else { + # use void context during scan pass + $hooks{preprocess}{$command}{call}->( + @params, + page => $page, + destpage => $destpage, + preview => $preprocess_preview, + ); + $ret=""; + } $preprocessing{$page}--; return $ret; } -- cgit v1.2.3