Browse Source

Merge pull request #4 in EAGLE6/mungedb-aggregate from bugfix/ENTERSCAPE-2139-debug-database-process-pegged to release/v0.6.9+2014.03.07

* commit '4404edccc68abf02917cecb32824da3ed21d9d1e':
  Refs ENTERSCAPE-2139. Fixed sort constantly creating new objects during comparisons.
Chris Sexton 11 years ago
parent
commit
264e6a62d8
1 changed files with 5 additions and 1 deletions
  1. 5 1
      lib/pipeline/documentSources/SortDocumentSource.js

+ 5 - 1
lib/pipeline/documentSources/SortDocumentSource.js

@@ -143,6 +143,10 @@ proto.populate = function populate() {
 		this.documents.push(doc);
 	}
 
+	this.vSortKeyFPEs = this.vSortKey.map(function(aSortKey){
+		return new FieldPathExpression(aSortKey.getFieldPath(false));
+	});
+
 	/* sort the list */
 	this.documents.sort(SortDocumentSource.prototype.compare.bind(this));
 
@@ -173,7 +177,7 @@ proto.compare = function compare(pL,pR) {
 	var n = this.vSortKey.length;
 	for(var i = 0; i < n; ++i) {
 		/* evaluate the sort keys */
-		var pathExpr = new FieldPathExpression(this.vSortKey[i].getFieldPath(false));
+		var pathExpr = this.vSortKeyFPEs[i];
 		var left = pathExpr.evaluate(pL), right = pathExpr.evaluate(pR);
 
 		/*