Skip to content

Commit 073ff3d

Browse files
committed
Improve style and speed
Replace delete with "= undefined".
1 parent b6a8e60 commit 073ff3d

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

lib/mj-single.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -508,26 +508,26 @@ function GetSVG(result) {
508508
function GetPNG(result) {
509509
var s = new Readable();
510510
var pngScale = 2;
511-
var svgFile = result.svgfile; delete result.svgfile;
512-
var width = result.width; delete result.width;
513-
var height = result.height; delete result.height;
511+
var svgFile = result.svgfile; result.svgfile=undefined;
512+
var width = result.width; result.width=undefined;
513+
var height = result.height; result.height=undefined;
514514
if (data.png) {
515-
var svgRenderer = new rsvg();
516-
s._read = function () {
517-
s.push(svgFile);
518-
s.push(null);
519-
};
520-
var synch = MathJax.Callback(function () {}); // for synchronization with MathJax
521-
svgRenderer.on('finish', function () {
522-
var buffer = svgRenderer.render({
523-
format: 'png',
524-
width: width * pngScale,
525-
height: height * pngScale
526-
}).data;
527-
result.png = "data:image/png;base64," + (buffer || "").toString('base64');
528-
synch();
529-
});
530-
s.pipe(svgRenderer);
515+
var svgRenderer = new rsvg();
516+
s._read = function () {
517+
s.push(svgFile);
518+
s.push(null);
519+
};
520+
var synch = MathJax.Callback(function () {}); // for synchronization with MathJax
521+
svgRenderer.on('finish', function () {
522+
var buffer = svgRenderer.render({
523+
format: 'png',
524+
width: width * pngScale,
525+
height: height * pngScale
526+
}).data;
527+
result.png = "data:image/png;base64," + (buffer || "").toString('base64');
528+
synch();
529+
});
530+
s.pipe(svgRenderer);
531531
return synch; // This keeps the queue from continuing until the readFile() is complete
532532
}
533533
}

0 commit comments

Comments
 (0)