]> git.parisson.com Git - pdf.js.git/commitdiff
Cleanup the way getIRQueue is called (no need to pass in a queue object in most cases...
authorJulian Viereck <julian.viereck@gmail.com>
Tue, 21 Feb 2012 13:28:42 +0000 (14:28 +0100)
committerJulian Viereck <julian.viereck@gmail.com>
Fri, 16 Mar 2012 13:56:43 +0000 (14:56 +0100)
src/core.js
src/evaluator.js

index 01bbc85233be8ce1a1b0f9551380b74d64cdfaa2..b62302a9c2331de73b25c85bb1280ad39720cfd7 100644 (file)
@@ -213,9 +213,8 @@ var Page = (function PageClosure() {
 
       var pe = this.pe = new PartialEvaluator(
                                 xref, handler, 'p' + this.pageNumber + '_');
-      var IRQueue = {};
-      this.IRQueue = pe.getIRQueue(content, resources, IRQueue, dependency);
 
+      this.IRQueue = pe.getIRQueue(content, resources, dependency);
       this.stats.timeEnd('Build IR Queue');
       return this.IRQueue;
     },
index e34787e412536411a42eea4ee5d90903c6174c22..51d86564bc355383d7a216b767c328a38a3fe0cd 100644 (file)
@@ -113,7 +113,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 
   PartialEvaluator.prototype = {
     getIRQueue: function partialEvaluatorGetIRQueue(stream, resources,
-                                    queue, dependency) {
+                                                      dependency, queue) {
 
       var self = this;
       var xref = this.xref;
@@ -136,8 +136,6 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 
         var fontRes = resources.get('Font');
 
-        // TODO: TOASK: Is it possible to get here? If so, what does
-        // args[0].name should be like???
         assert(fontRes, 'fontRes not available');
 
         fontRes = xref.fetchIfRef(fontRes);
@@ -177,7 +175,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
 
         // Ensure the font is ready before the font is set
         // and later on used for drawing.
-        // TODO: This should get insert to the IRQueue only once per
+        // OPTIMIZE: This should get insert to the IRQueue only once per
         // page.
         insertDependency([loadedName]);
         return loadedName;
@@ -239,6 +237,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
           }, handler, xref, resources, image, inline);
       }
 
+      if (!queue)
+        queue = {};
+
       if (!queue.argsArray) {
         queue.argsArray = [];
       }
@@ -295,9 +296,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
                 if (typeNum == TILING_PATTERN) {
                   // Create an IR of the pattern code.
                   var depIdx = dependencyArray.length;
-                  var queueObj = {};
                   var codeIR = this.getIRQueue(pattern, dict.get('Resources') ||
-                      resources, queueObj, dependencyArray);
+                      resources, dependencyArray);
 
                   // Add the dependencies that are required to execute the
                   // codeIR.
@@ -340,8 +340,11 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
                 // This adds the IRQueue of the xObj to the current queue.
                 var depIdx = dependencyArray.length;
 
+                // Pass in the current `queue` object. That means the `fnArray`
+                // and the `argsArray` in this scope is reused and new commands
+                // are added to them.
                 this.getIRQueue(xobj, xobj.dict.get('Resources') || resources,
-                    queue, dependencyArray);
+                    dependencyArray, queue);
 
                // Add the dependencies that are required to execute the
                // codeIR.
@@ -454,10 +457,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
         }
       }
 
-      return {
-        fnArray: fnArray,
-        argsArray: argsArray
-      };
+      return queue;
     },
 
     extractDataStructures: function
@@ -858,9 +858,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
         properties.charProcIRQueues = {};
         for (var key in charProcs.map) {
           var glyphStream = xref.fetchIfRef(charProcs.map[key]);
-          var queueObj = {};
           properties.charProcIRQueues[key] =
-            this.getIRQueue(glyphStream, fontResources, queueObj, dependency);
+            this.getIRQueue(glyphStream, fontResources, dependency);
         }
       }