From 33dd1b0c3c58acf677486c20e85d5bd3870e555d Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 24 Feb 2014 16:45:18 -0800 Subject: [PATCH 1/2] Remove the unnecessary this.buf in CCITTFaxStream. --- src/core/stream.js | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/core/stream.js b/src/core/stream.js index 7567081c9..696833f2e 100644 --- a/src/core/stream.js +++ b/src/core/stream.js @@ -1688,7 +1688,6 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() { this.inputBits = 0; this.inputBuf = 0; this.outputBits = 0; - this.buf = EOF; var code1; while ((code1 = this.lookBits(12)) === 0) { @@ -1710,7 +1709,6 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() { CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() { while (!this.eof) { var c = this.lookChar(); - this.buf = EOF; this.ensureBuffer(this.bufferLength + 1); this.buffer[this.bufferLength++] = c; } @@ -1766,9 +1764,6 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() { }; CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() { - if (this.buf != EOF) - return this.buf; - var refLine = this.refLine; var codingLine = this.codingLine; var columns = this.columns; @@ -2014,8 +2009,9 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() { this.row++; } + var c; if (this.outputBits >= 8) { - this.buf = (this.codingPos & 1) ? 0 : 0xFF; + c = (this.codingPos & 1) ? 0 : 0xFF; this.outputBits -= 8; if (this.outputBits === 0 && codingLine[this.codingPos] < columns) { this.codingPos++; @@ -2024,19 +2020,19 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() { } } else { var bits = 8; - this.buf = 0; + c = 0; do { if (this.outputBits > bits) { - this.buf <<= bits; + c <<= bits; if (!(this.codingPos & 1)) { - this.buf |= 0xFF >> (8 - bits); + c |= 0xFF >> (8 - bits); } this.outputBits -= bits; bits = 0; } else { - this.buf <<= this.outputBits; + c <<= this.outputBits; if (!(this.codingPos & 1)) { - this.buf |= 0xFF >> (8 - this.outputBits); + c |= 0xFF >> (8 - this.outputBits); } bits -= this.outputBits; this.outputBits = 0; @@ -2045,16 +2041,16 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() { this.outputBits = (codingLine[this.codingPos] - codingLine[this.codingPos - 1]); } else if (bits > 0) { - this.buf <<= bits; + c <<= bits; bits = 0; } } } while (bits); } if (this.black) { - this.buf ^= 0xFF; + c ^= 0xFF; } - return this.buf; + return c; }; // This functions returns the code found from the table. From d4e8b41639bde03bab4520caa7e60358ddc8d045 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 24 Feb 2014 18:17:06 -0800 Subject: [PATCH 2/2] Remove some unnecessary local variables. --- src/core/evaluator.js | 2 -- web/text_layer_builder.js | 5 +---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 2e85cbd16..caca65d85 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -87,8 +87,6 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { xobj, smask, operatorList, state) { - var self = this; - var matrix = xobj.dict.get('Matrix'); var bbox = xobj.dict.get('BBox'); var group = xobj.dict.get('Group'); diff --git a/web/text_layer_builder.js b/web/text_layer_builder.js index c2f8043ea..a81457f9f 100644 --- a/web/text_layer_builder.js +++ b/web/text_layer_builder.js @@ -60,10 +60,7 @@ var TextLayerBuilder = function textLayerBuilder(options) { }; this.renderLayer = function textLayerBuilderRenderLayer() { - var self = this; var textDivs = this.textDivs; - var bidiTexts = this.textContent; - var textLayerDiv = this.textLayerDiv; var canvas = document.createElement('canvas'); var ctx = canvas.getContext('2d'); @@ -93,7 +90,7 @@ var TextLayerBuilder = function textLayerBuilder(options) { } } - textLayerDiv.appendChild(textLayerFrag); + this.textLayerDiv.appendChild(textLayerFrag); this.renderingDone = true; this.updateMatches(); };