[Pkg-javascript-commits] [pdf.js] 17/246: Use Array.join to build up strings in readPostScriptTable().

David Prévot taffit at moszumanska.debian.org
Sun Sep 7 15:36:20 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 103979147253e60682f5beb80c116b6a1c7a178e
Author: Nicholas Nethercote <nnethercote at mozilla.com>
Date:   Wed Jul 23 22:17:56 2014 -0700

    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 daf6257..3ac32be 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) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list