]> git.parisson.com Git - pdf.js.git/commitdiff
LZW reducing memory usage
authornotmasteryet <async.processingjs@yahoo.com>
Thu, 18 Aug 2011 12:43:45 +0000 (07:43 -0500)
committernotmasteryet <async.processingjs@yahoo.com>
Thu, 18 Aug 2011 12:43:45 +0000 (07:43 -0500)
pdf.js

diff --git a/pdf.js b/pdf.js
index 2afed5f6b687cabaf2c39b239f54fa4376c1b850..eab5a35e292a53a8f63ff3107e0d4f78352bcb5b 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -1990,7 +1990,7 @@ var LZWStream = (function() {
     this.cachedData = 0;
     this.bitsCached = 0;
 
-    var maxLzwDictionarySize = 4097;
+    var maxLzwDictionarySize = 4096;
     var lzwState = {
       earlyChange: earlyChange,
       codeLength: 9,
@@ -2036,6 +2036,9 @@ var LZWStream = (function() {
     var i, j, q;
 
     var lzwState = this.lzwState;
+    if (!lzwState)
+      return; // eof was found
+
     var earlyChange = lzwState.earlyChange;
     var nextCode = lzwState.nextCode;
     var dictionaryValues = lzwState.dictionaryValues;
@@ -2073,6 +2076,7 @@ var LZWStream = (function() {
         continue;
       } else {
         this.eof = true;
+        delete this.lzwState;
         break;
       }