mirror of
https://github.com/nasa/openmct.git
synced 2025-02-20 09:26:45 +00:00
[Search] Changed array to dictionary
for faster lookup times in the search aggregator's filterDuplicated function.
This commit is contained in:
parent
c869aaf91a
commit
bbce5c3154
@ -46,12 +46,12 @@ define(
|
||||
// Remove duplicate objects that have the same ID. Modifies the passed
|
||||
// array, and returns the number that were removed.
|
||||
function filterDuplicates(results, total) {
|
||||
var ids = [],
|
||||
var ids = {},
|
||||
numRemoved = 0,
|
||||
i;
|
||||
|
||||
for (i = 0; i < results.length; i += 1) {
|
||||
if (ids.indexOf(results[i].id) !== -1) {
|
||||
if (ids[results[i].id]) {
|
||||
// If this result's ID is already there, remove the object
|
||||
results.splice(i, 1);
|
||||
numRemoved += 1;
|
||||
@ -60,7 +60,7 @@ define(
|
||||
i -= 1;
|
||||
} else {
|
||||
// Otherwise add the ID to the list of the ones we have seen
|
||||
ids.push(results[i].id);
|
||||
ids[results[i].id] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user