Buffer png writes and flush them all at once
* This should half the time to render pages with many formulas bug: 56769 Change-Id: I5edf979c31fe12098eba1d1df52c9cd3251bd115
This commit is contained in:
parent
48669ebbdc
commit
f0f19007c5
|
@ -3,3 +3,4 @@
|
|||
*~
|
||||
*.kate-swp
|
||||
.*.swp
|
||||
/nbproject/private/
|
|
@ -126,7 +126,7 @@ class MathTexvc extends MathRenderer {
|
|||
* @return int|string MW_TEXVC_SUCCESS or error string
|
||||
*/
|
||||
public function callTexvc() {
|
||||
global $wgTexvc, $wgTexvcBackgroundColor, $wgUseSquid, $wgMathCheckFiles;
|
||||
global $wgTexvc, $wgTexvcBackgroundColor, $wgUseSquid, $wgMathCheckFiles, $wgHooks;
|
||||
|
||||
wfProfileIn( __METHOD__ );
|
||||
$tmpDir = wfTempDir();
|
||||
|
@ -237,13 +237,23 @@ class MathTexvc extends MathRenderer {
|
|||
return $this->getError( 'math_output_error' );
|
||||
}
|
||||
// Store the file at the final storage path...
|
||||
if ( !$backend->quickStore( array(
|
||||
'src' => "$tmpDir/{$this->getHash()}.png", 'dst' => "$hashpath/{$this->getHash()}.png"
|
||||
) )->isOK()
|
||||
) {
|
||||
wfProfileOut( __METHOD__ );
|
||||
return $this->getError( 'math_output_error' );
|
||||
// Bug 56769: buffer the writes and do them at the end.
|
||||
if ( !isset( $wgHooks['ParserAfterParse']['FlushMathBackend'] ) ) {
|
||||
$backend->mathBufferedWrites = array();
|
||||
$wgHooks['ParserAfterParse']['FlushMathBackend'] = function() use ( $backend ) {
|
||||
global $wgHooks;
|
||||
unset( $wgHooks['ParserAfterParse']['FlushMathBackend'] );
|
||||
$backend->doQuickOperations( $backend->mathBufferedWrites );
|
||||
unset( $backend->mathBufferedWrites );
|
||||
};
|
||||
}
|
||||
$backend->mathBufferedWrites[] = array(
|
||||
'op' => 'store',
|
||||
'src' => "$tmpDir/{$this->getHash()}.png",
|
||||
'dst' => "$hashpath/{$this->getHash()}.png",
|
||||
'ref' => $tempFsFile // keep file alive
|
||||
);
|
||||
|
||||
wfProfileOut( __METHOD__ );
|
||||
return self::MW_TEXVC_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue