From 96b9af68ddc4a3374f1d77eff1a5e8c20e67005d Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Sun, 17 Aug 2014 22:21:45 -0700 Subject: [PATCH] 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 e33c211068dc6..e48348dc2e0fd 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]);