Browse Source

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.
Nicholas Nethercote 11 years ago
parent
commit
96b9af68dd
  1. 21
      src/core/evaluator.js

21
src/core/evaluator.js

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

Loading…
Cancel
Save