From: Joey Hess Date: Wed, 9 Jan 2008 07:30:46 +0000 (-0500) Subject: Call preprocessor hooks in void context during the scan pass. X-Git-Tag: 2.20~20 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=50faf0b151e08887b686e88d525b3b3e3b5379e5;p=ikiwiki.git 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. --- 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; }