Add a totalLength getter to OperatorList, since the length is zero after flushing

In the `RenderPageRequest` handler in `worker.js`, we attempt to print an `info` message containing the rendering time and the length of the operator list. The latter is currently broken (and has been for quite some time), since the `length` of an `OperatorList` is reset when flushing occurs.
This patch attempts to rectify this, by adding a getter which keeps track of the total length.
This commit is contained in:
Jonas Jenwald 2015-10-26 16:38:06 +01:00
parent aae82ec4c5
commit 1c66d4a106
3 changed files with 35 additions and 2 deletions

View file

@ -1920,6 +1920,7 @@ var OperatorList = (function OperatorListClosure() {
this.fnArray = [];
this.argsArray = [];
this.dependencies = {};
this._totalLength = 0;
this.pageIndex = pageIndex;
this.intent = intent;
}
@ -1929,6 +1930,14 @@ var OperatorList = (function OperatorListClosure() {
return this.argsArray.length;
},
/**
* @returns {number} The total length of the entire operator list,
* since `this.length === 0` after flushing.
*/
get totalLength() {
return (this._totalLength + this.length);
},
addOp: function(fn, args) {
this.fnArray.push(fn);
this.argsArray.push(args);
@ -1977,12 +1986,15 @@ var OperatorList = (function OperatorListClosure() {
new QueueOptimizer().optimize(this);
}
var transfers = getTransfers(this);
var length = this.length;
this._totalLength += length;
this.messageHandler.send('RenderPageChunk', {
operatorList: {
fnArray: this.fnArray,
argsArray: this.argsArray,
lastChunk: lastChunk,
length: this.length
length: length
},
pageIndex: this.pageIndex,
intent: this.intent