[Pkg-javascript-commits] [pdf.js] 229/246: Remove setGStateForKey() closure.

David Prévot taffit at moszumanska.debian.org
Sun Sep 7 15:36:44 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 96b9af68ddc4a3374f1d77eff1a5e8c20e67005d
Author: Nicholas Nethercote <nnethercote at mozilla.com>
Date:   Sun Aug 17 22:21:45 2014 -0700

    Remove setGStateForKey() closure.
    
    setGStateForKey() is a closure that serves no particularly useful
    purpose. This change inlines it at the single call site. This avoids 1.7
    MiB of allocations (because closures are objects) for the MTA map
    mentioned in https://bugzilla.mozilla.org/show_bug.cgi?id=835380#c17.
---
 src/core/evaluator.js | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index e33c211..e48348d 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -363,10 +363,13 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
     setGState: function PartialEvaluator_setGState(resources, gState,
                                                    operatorList, xref,
                                                    stateManager) {
-
-      // TODO(mack): This should be rewritten so that this function returns
-      // what should be added to the queue during each iteration
-      function setGStateForKey(gStateObj, key, value) {
+      // This array holds the converted/processed state data.
+      var gStateObj = [];
+      var gStateMap = gState.map;
+      var self = this;
+      var promise = Promise.resolve();
+      for (var key in gStateMap) {
+        var value = gStateMap[key];
         switch (key) {
           case 'Type':
             break;
@@ -435,16 +438,6 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
             break;
         }
       }
-
-      // This array holds the converted/processed state data.
-      var gStateObj = [];
-      var gStateMap = gState.map;
-      var self = this;
-      var promise = Promise.resolve();
-      for (var key in gStateMap) {
-        var value = gStateMap[key];
-        setGStateForKey(gStateObj, key, value);
-      }
       return promise.then(function () {
         if (gStateObj.length >= 0) {
           operatorList.addOp(OPS.setGState, [gStateObj]);

-- 
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