From f5bec2e41e444887ce4779d288410cc7c71760b8 Mon Sep 17 00:00:00 2001 From: Ryc O'Chet Date: Fri, 16 Sep 2016 15:52:22 +0100 Subject: [PATCH] decompressFromUint8Array optmisation Remove the redundant temporary buffer, and push the output character directly into the output buffer. This saves memory and is quicker as it doesn't need to iterate twice. --- libs/lz-string.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/libs/lz-string.js b/libs/lz-string.js index 1194e25..96c4915 100644 --- a/libs/lz-string.js +++ b/libs/lz-string.js @@ -73,19 +73,11 @@ var LZString = { if (compressed===null || compressed===undefined){ return LZString.decompress(compressed); } else { - var buf=new Array(compressed.length/2); // 2 bytes per character - for (var i=0, TotalLen=buf.length; i