Browse Source

Merge pull request #4972 from nnethercote/preprocessor-read

Avoid allocating return object in EvaluatorPreprocessor_read().
Yury Delendik 11 years ago
parent
commit
b557b87fc9
  1. 17
      src/core/evaluator.js

17
src/core/evaluator.js

@ -638,9 +638,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
return new Promise(function next(resolve, reject) { return new Promise(function next(resolve, reject) {
timeSlotManager.reset(); timeSlotManager.reset();
var stop, operation, i, ii, cs; var stop, operation = {}, i, ii, cs;
while (!(stop = timeSlotManager.check()) && while (!(stop = timeSlotManager.check()) &&
(operation = preprocessor.read())) { preprocessor.read(operation)) {
var args = operation.args; var args = operation.args;
var fn = operation.fn; var fn = operation.fn;
@ -894,7 +894,6 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager); var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
var operation;
var textState; var textState;
function newTextChunk() { function newTextChunk() {
@ -1032,9 +1031,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
return new Promise(function next(resolve, reject) { return new Promise(function next(resolve, reject) {
timeSlotManager.reset(); timeSlotManager.reset();
var stop; var stop, operation = {};
while (!(stop = timeSlotManager.check()) && while (!(stop = timeSlotManager.check()) &&
(operation = preprocessor.read())) { (preprocessor.read(operation))) {
textState = stateManager.state; textState = stateManager.state;
var fn = operation.fn; var fn = operation.fn;
var args = operation.args; var args = operation.args;
@ -2099,12 +2098,12 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
return this.stateManager.stateStack.length; return this.stateManager.stateStack.length;
}, },
read: function EvaluatorPreprocessor_read() { read: function EvaluatorPreprocessor_read(operation) {
var args = []; var args = [];
while (true) { while (true) {
var obj = this.parser.getObj(); var obj = this.parser.getObj();
if (isEOF(obj)) { if (isEOF(obj)) {
return null; // no more commands return false; // no more commands
} }
if (!isCmd(obj)) { if (!isCmd(obj)) {
// argument // argument
@ -2155,7 +2154,9 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
// TODO figure out how to type-check vararg functions // TODO figure out how to type-check vararg functions
this.preprocessCommand(fn, args); this.preprocessCommand(fn, args);
return { fn: fn, args: args }; operation.fn = fn;
operation.args = args;
return true;
} }
}, },

Loading…
Cancel
Save