From 63fd615589a75db6b72f08f69c84d5d1dab94da9 Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Mon, 22 Sep 2014 16:33:23 -0500 Subject: [PATCH] PDF.js version 1.0.678 --- bower.json | 2 +- build/pdf.combined.js | 56 ++++++++++++++++++++++++++++++++++--------- build/pdf.js | 4 ++-- build/pdf.worker.js | 56 ++++++++++++++++++++++++++++++++++--------- package.json | 2 +- 5 files changed, 94 insertions(+), 26 deletions(-) diff --git a/bower.json b/bower.json index 32c4f560b..2a4850ac3 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.0.676", + "version": "1.0.678", "keywords": [ "Mozilla", "pdf", diff --git a/build/pdf.combined.js b/build/pdf.combined.js index cbe9481a2..bcf6ccf8e 100644 --- a/build/pdf.combined.js +++ b/build/pdf.combined.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.676'; -PDFJS.build = '9d87cbc'; +PDFJS.version = '1.0.678'; +PDFJS.build = '9b480d7'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -16630,8 +16630,15 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { return new Promise(function next(resolve, reject) { timeSlotManager.reset(); var stop, operation = {}, i, ii, cs; - while (!(stop = timeSlotManager.check()) && - preprocessor.read(operation)) { + while (!(stop = timeSlotManager.check())) { + // The arguments parsed by read() are used beyond this loop, so we + // cannot reuse the same array on each iteration. Therefore we pass + // in |null| as the initial value (see the comment on + // EvaluatorPreprocessor_read() for why). + operation.args = null; + if (!(preprocessor.read(operation))) { + break; + } var args = operation.args; var fn = operation.fn; @@ -17025,12 +17032,20 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { return new Promise(function next(resolve, reject) { timeSlotManager.reset(); - var stop, operation = {}; - while (!(stop = timeSlotManager.check()) && - (preprocessor.read(operation))) { + var stop, operation = {}, args = []; + while (!(stop = timeSlotManager.check())) { + // The arguments parsed by read() are not used beyond this loop, so + // we can reuse the same array on every iteration, thus avoiding + // unnecessary allocations. + args.length = 0; + operation.args = args; + if (!(preprocessor.read(operation))) { + break; + } textState = stateManager.state; var fn = operation.fn; - var args = operation.args; + args = operation.args; + switch (fn | 0) { case OPS.setFont: textState.fontSize = args[1]; @@ -18100,10 +18115,29 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() { return this.stateManager.stateStack.length; }, + // |operation| is an object with two fields: + // + // - |fn| is an out param. + // + // - |args| is an inout param. On entry, it should have one of two values. + // + // - An empty array. This indicates that the caller is providing the + // array in which the args will be stored in. The caller should use + // this value if it can reuse a single array for each call to read(). + // + // - |null|. This indicates that the caller needs this function to create + // the array in which any args are stored in. If there are zero args, + // this function will leave |operation.args| as |null| (thus avoiding + // allocations that would occur if we used an empty array to represent + // zero arguments). Otherwise, it will replace |null| with a new array + // containing the arguments. The caller should use this value if it + // cannot reuse an array for each call to read(). + // + // These two modes are present because this function is very hot and so + // avoiding allocations where possible is worthwhile. + // read: function EvaluatorPreprocessor_read(operation) { - // We use an array to represent args, except we use |null| to represent - // no args because it's more compact than an empty array. - var args = null; + var args = operation.args; while (true) { var obj = this.parser.getObj(); if (isCmd(obj)) { diff --git a/build/pdf.js b/build/pdf.js index 6dfd3dd70..42ef39a4b 100644 --- a/build/pdf.js +++ b/build/pdf.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.676'; -PDFJS.build = '9d87cbc'; +PDFJS.version = '1.0.678'; +PDFJS.build = '9b480d7'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it diff --git a/build/pdf.worker.js b/build/pdf.worker.js index bee548424..65cd48ec9 100644 --- a/build/pdf.worker.js +++ b/build/pdf.worker.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.676'; -PDFJS.build = '9d87cbc'; +PDFJS.version = '1.0.678'; +PDFJS.build = '9b480d7'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -10647,8 +10647,15 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { return new Promise(function next(resolve, reject) { timeSlotManager.reset(); var stop, operation = {}, i, ii, cs; - while (!(stop = timeSlotManager.check()) && - preprocessor.read(operation)) { + while (!(stop = timeSlotManager.check())) { + // The arguments parsed by read() are used beyond this loop, so we + // cannot reuse the same array on each iteration. Therefore we pass + // in |null| as the initial value (see the comment on + // EvaluatorPreprocessor_read() for why). + operation.args = null; + if (!(preprocessor.read(operation))) { + break; + } var args = operation.args; var fn = operation.fn; @@ -11042,12 +11049,20 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { return new Promise(function next(resolve, reject) { timeSlotManager.reset(); - var stop, operation = {}; - while (!(stop = timeSlotManager.check()) && - (preprocessor.read(operation))) { + var stop, operation = {}, args = []; + while (!(stop = timeSlotManager.check())) { + // The arguments parsed by read() are not used beyond this loop, so + // we can reuse the same array on every iteration, thus avoiding + // unnecessary allocations. + args.length = 0; + operation.args = args; + if (!(preprocessor.read(operation))) { + break; + } textState = stateManager.state; var fn = operation.fn; - var args = operation.args; + args = operation.args; + switch (fn | 0) { case OPS.setFont: textState.fontSize = args[1]; @@ -12117,10 +12132,29 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() { return this.stateManager.stateStack.length; }, + // |operation| is an object with two fields: + // + // - |fn| is an out param. + // + // - |args| is an inout param. On entry, it should have one of two values. + // + // - An empty array. This indicates that the caller is providing the + // array in which the args will be stored in. The caller should use + // this value if it can reuse a single array for each call to read(). + // + // - |null|. This indicates that the caller needs this function to create + // the array in which any args are stored in. If there are zero args, + // this function will leave |operation.args| as |null| (thus avoiding + // allocations that would occur if we used an empty array to represent + // zero arguments). Otherwise, it will replace |null| with a new array + // containing the arguments. The caller should use this value if it + // cannot reuse an array for each call to read(). + // + // These two modes are present because this function is very hot and so + // avoiding allocations where possible is worthwhile. + // read: function EvaluatorPreprocessor_read(operation) { - // We use an array to represent args, except we use |null| to represent - // no args because it's more compact than an empty array. - var args = null; + var args = operation.args; while (true) { var obj = this.parser.getObj(); if (isCmd(obj)) { diff --git a/package.json b/package.json index 330874348..d127d824d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.0.676", + "version": "1.0.678", "description": "Generic build of Mozilla's PDF.js library.", "keywords": [ "Mozilla",