Use Array.join to build up strings in readPostScriptTable().

This avoids about 5 MiB of string allocations on one test case.
This commit is contained in:
Nicholas Nethercote 2014-07-23 22:17:56 -07:00
parent 584fef90ab
commit 1039791472

View File

@ -3430,13 +3430,14 @@ var Font = (function FontClosure() {
break; break;
} }
var customNames = []; var customNames = [];
var strBuf = [];
while (font.pos < end) { while (font.pos < end) {
var stringLength = font.getByte(); var stringLength = font.getByte();
var string = ''; strBuf.length = stringLength;
for (i = 0; i < stringLength; ++i) { for (i = 0; i < stringLength; ++i) {
string += String.fromCharCode(font.getByte()); strBuf[i] = String.fromCharCode(font.getByte());
} }
customNames.push(string); customNames.push(strBuf.join(''));
} }
glyphNames = []; glyphNames = [];
for (i = 0; i < numGlyphs; ++i) { for (i = 0; i < numGlyphs; ++i) {