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-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/commitdiff_plain/50faf0b151e08887b686e88d525b3b3e3b5379e5?hp=65db156614d7d5dffaeb16f338c5702c4d5945df 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; }