From 103979147253e60682f5beb80c116b6a1c7a178e Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 23 Jul 2014 22:17:56 -0700 Subject: [PATCH] Use Array.join to build up strings in readPostScriptTable(). This avoids about 5 MiB of string allocations on one test case. --- src/core/fonts.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/fonts.js b/src/core/fonts.js index daf6257d4..3ac32be7b 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -3430,13 +3430,14 @@ var Font = (function FontClosure() { break; } var customNames = []; + var strBuf = []; while (font.pos < end) { var stringLength = font.getByte(); - var string = ''; + strBuf.length = stringLength; 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 = []; for (i = 0; i < numGlyphs; ++i) {