mirror of
https://github.com/nasa/openmct.git
synced 2025-02-22 10:11:06 +00:00
[Search] New item indexer
This one (hopefully) doesn't fill up the call stack when there are lots of items.
This commit is contained in:
parent
ae763d000c
commit
1fe492cc3d
@ -121,23 +121,20 @@ define(
|
|||||||
worker.onmessage = handleResponse;
|
worker.onmessage = handleResponse;
|
||||||
|
|
||||||
// Helper function for getItems(). Indexes the tree.
|
// Helper function for getItems(). Indexes the tree.
|
||||||
function itemsHelper(children, i) {
|
function indexItems(nodes) {
|
||||||
// Index the current node
|
var i;
|
||||||
indexItem(children[i]);
|
|
||||||
|
|
||||||
if (i >= children.length) {
|
for (i = 0; i < nodes.length; i += 1) {
|
||||||
// Done!
|
// Index each item with the web worker
|
||||||
return children;
|
indexItem(nodes[i]);
|
||||||
} else if (children[i].hasCapability('composition')) {
|
|
||||||
// This child has children
|
if (nodes[i].hasCapability('composition')) {
|
||||||
return children[i].getCapability('composition').invoke().then(function (grandchildren) {
|
// This node has children
|
||||||
// Add grandchildren to the end of the list
|
nodes[i].getCapability('composition').invoke().then(function (children) {
|
||||||
// They will also be checked for composition
|
// Index the children
|
||||||
return itemsHelper(children.concat(grandchildren), i + 1);
|
indexItems(children);
|
||||||
});
|
});
|
||||||
} else {
|
}
|
||||||
// This child is a leaf
|
|
||||||
return itemsHelper(children, i + 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +151,7 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Index all of the roots' descendents
|
// Index all of the roots' descendents
|
||||||
itemsHelper(objects, 0);
|
indexItems(objects);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user