From 2b6cb317db1e64017036bb0f7d35ee940d6133ef Mon Sep 17 00:00:00 2001 From: p01 Date: Mon, 10 Mar 2014 14:58:32 +0100 Subject: [PATCH] Optmized decodeRefinement, moving the prediction error outside the inner loop There is no need to slow down the inner loop with a test for ltp as it can only change if prediction is true in which case it only changes in the outer loop. --- src/core/jbig2.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/jbig2.js b/src/core/jbig2.js index 0b9a1546e..23d4bd54b 100755 --- a/src/core/jbig2.js +++ b/src/core/jbig2.js @@ -376,13 +376,13 @@ var Jbig2Image = (function Jbig2ImageClosure() { if (prediction) { var sltp = decoder.readBit(contexts, pseudoPixelContext); ltp ^= sltp; + if (ltp) { + error('JBIG2 error: prediction is not supported'); + } } var row = new Uint8Array(width); bitmap.push(row); for (var j = 0; j < width; j++) { - if (ltp) { - error('JBIG2 error: prediction is not supported'); - } var contextLabel = 0; for (var k = 0; k < codingTemplateLength; k++) {