From 639cf1cf592c003786292eb94b78e93329c5e1a8 Mon Sep 17 00:00:00 2001 From: slhale Date: Wed, 29 Jul 2015 10:26:24 -0700 Subject: [PATCH] [Search] Generic indexes once Changed the generic search provider to index the file tree only once when it is initially called. This assumes that the contents of the file tree will not change significantly within the course of a use session (and some changes may be caught by other search providers). --- .../src/providers/GenericSearchProvider.js | 16 ++++++++++++++++ .../search/src/workers/GenericSearchWorker.js | 1 - 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/platform/features/search/src/providers/GenericSearchProvider.js b/platform/features/search/src/providers/GenericSearchProvider.js index a5cbe73ce8..966bdf2f59 100644 --- a/platform/features/search/src/providers/GenericSearchProvider.js +++ b/platform/features/search/src/providers/GenericSearchProvider.js @@ -181,14 +181,30 @@ define( maxResults = DEFAULT_MAX_RESULTS; } + /* // Get items list return getItems(timeout).then(function () { // Then get the worker to search through it workerSearch(input, maxResults, timestamp); return; // There's nothing we need to return here }); + */ + + // Instead, assume that the items have already been indexed, and + // just send the query to the worker. + + workerSearch(input, maxResults, timestamp); + return; } + // Index the tree's contents once at the beginning + // TODO: Is this a good assumption that the tree's contents will not + // change often enough? + // TODO: This makes the timeout parameter that queryGeneric takes + // useless. See if timing out worker is an idea that works. + getItems(); + + return { /** * Searches through the filetree for domain objects which match diff --git a/platform/features/search/src/workers/GenericSearchWorker.js b/platform/features/search/src/workers/GenericSearchWorker.js index 5ee8393b73..4f2dbfbc2e 100644 --- a/platform/features/search/src/workers/GenericSearchWorker.js +++ b/platform/features/search/src/workers/GenericSearchWorker.js @@ -34,7 +34,6 @@ // Helper function for index() function conainsItem(id) { var i; - for (i = 0; i < indexedItems.length; i += 1) { if (indexedItems[i].id === id) { return true;