From a4920c223ec829baaaa4db103acf711e278b6051 Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Sun, 2 Oct 2022 22:04:27 +0200 Subject: [PATCH] Faster startup indexing --- src/search.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/search.ts b/src/search.ts index d04bcf7..c89a46a 100644 --- a/src/search.ts +++ b/src/search.ts @@ -100,14 +100,16 @@ export async function initGlobalSearchIndex(): Promise { // This is basically the same behavior as MiniSearch's `addAllAsync()`. // We index markdown and plaintext files by batches of 10 + const promises: Promise[] = [] for (let i = 0; i < files.length; ++i) { if (i % 10 === 0) await wait(0) const file = files[i] if (getNoteFromCache(file.path)) { removeFromIndex(file.path) } - await addToIndex(file) + promises.push(addToIndex(file)) } + await Promise.all(promises) if (files.length > 0) { const message = `Omnisearch - Indexed ${files.length} ${notesSuffix} in ${