From 2d352ac57445ade8bf4cf47feb3e33d08a0edf92 Mon Sep 17 00:00:00 2001 From: Pete Richards Date: Fri, 21 Apr 2017 11:35:11 -0700 Subject: [PATCH] only dupe check when needed Only enable datum dupe checking in collection after data has been received. This works under the assumption that a single telemetry request will not contain duplicate elements, thus, it is not necessary to check for dupes on the initial request. Improves performance when rows are sorted by a column that has duplicate row-values. --- platform/features/table/src/TelemetryCollection.js | 3 ++- .../features/table/src/controllers/TelemetryTableController.js | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/features/table/src/TelemetryCollection.js b/platform/features/table/src/TelemetryCollection.js index 3a6b2e43b0..e7463f1176 100644 --- a/platform/features/table/src/TelemetryCollection.js +++ b/platform/features/table/src/TelemetryCollection.js @@ -32,6 +32,7 @@ define( */ function TelemetryCollection() { EventEmitter.call(this, arguments); + this.dupeCheck = false; this.telemetry = []; this.highBuffer = []; this.sortField = undefined; @@ -161,7 +162,7 @@ define( var startIx = _.sortedIndex(array, item, this.sortField); var endIx; - if (startIx !== array.length) { + if (this.dupeCheck && startIx !== array.length) { endIx = _.sortedLastIndex(array, item, this.sortField); // Create an array of potential dupes, based on having the diff --git a/platform/features/table/src/controllers/TelemetryTableController.js b/platform/features/table/src/controllers/TelemetryTableController.js index 4018d61dd9..a24f0d7919 100644 --- a/platform/features/table/src/controllers/TelemetryTableController.js +++ b/platform/features/table/src/controllers/TelemetryTableController.js @@ -292,6 +292,7 @@ define( */ function finishProcessing() { telemetryCollection.add(rowData); + telemetryCollection.dupeCheck = true; scope.rows = telemetryCollection.telemetry; scope.loading = false; @@ -377,6 +378,7 @@ define( function newData(domainObject, datum) { limitEvaluator = telemetryApi.limitEvaluator(domainObject); added = telemetryCollection.add([table.getRowValues(limitEvaluator, datum)]); + this.telemetry.dupeCheck = true; } objects.forEach(function (object) {