[Pkg-javascript-commits] [pdf.js] 40/207: Minor refactoring of EvaluatorPreprocessor_read

David Prévot taffit at moszumanska.debian.org
Mon Jul 28 15:36:27 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 6731de6829d1ea7a1c627f736d993cd4c8283782
Author: p01 <p01 at opera.com>
Date:   Mon Jun 2 14:58:16 2014 +0200

    Minor refactoring of EvaluatorPreprocessor_read
---
 src/core/evaluator.js | 41 ++++++++++++++++++-----------------------
 1 file changed, 18 insertions(+), 23 deletions(-)

diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index c6ca1c3..15b6a1f 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2074,7 +2074,7 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
         }
         if (!isCmd(obj)) {
           // argument
-          if (obj != null) {
+          if (obj !== null) {
             args.push((obj instanceof Dict ? obj.getAll() : obj));
             assert(args.length <= 33, 'Too many arguments');
           }
@@ -2090,37 +2090,32 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
         }
 
         var fn = opSpec.id;
-
-        // Some post script commands can be nested, e.g. /F2 /GS2 gs 5.711 Tf
-        if (!opSpec.variableArgs && args.length !== opSpec.numArgs) {
-          while (args.length > opSpec.numArgs) {
-            this.nonProcessedArgs.push(args.shift());
-          }
-
-          while (args.length < opSpec.numArgs && this.nonProcessedArgs.length) {
-            args.unshift(this.nonProcessedArgs.pop());
+        var numArgs = opSpec.numArgs;
+
+        if (!opSpec.variableArgs) {
+          // Some post script commands can be nested, e.g. /F2 /GS2 gs 5.711 Tf
+          if (args.length !== numArgs) {
+            var nonProcessedArgs = this.nonProcessedArgs;
+            while (args.length > numArgs) {
+              nonProcessedArgs.push(args.shift());
+            }
+            while (args.length < numArgs && nonProcessedArgs.length !== 0) {
+              args.unshift(nonProcessedArgs.pop());
+            }
           }
-        }
 
-        // Validate the number of arguments for the command
-        if (opSpec.variableArgs) {
-          if (args.length > opSpec.numArgs) {
-            info('Command ' + fn + ': expected [0,' + opSpec.numArgs +
-                 '] args, but received ' + args.length + ' args');
-          }
-        } else {
-          if (args.length < opSpec.numArgs) {
+          if (args.length < numArgs) {
             // If we receive too few args, it's not possible to possible
             // to execute the command, so skip the command
             info('Command ' + fn + ': because expected ' +
-                 opSpec.numArgs + ' args, but received ' + args.length +
+                 numArgs + ' args, but received ' + args.length +
                  ' args; skipping');
             args = [];
             continue;
-          } else if (args.length > opSpec.numArgs) {
-            info('Command ' + fn + ': expected ' + opSpec.numArgs +
-                 ' args, but received ' + args.length + ' args');
           }
+        } else if (args.length > numArgs) {
+          info('Command ' + fn + ': expected [0,' + numArgs +
+               '] args, but received ' + args.length + ' args');
         }
 
         // TODO figure out how to type-check vararg functions

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list