From c5fa0806c82f1e6b81a5dfd91e7c0dd3f7c435ab Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Mon, 18 Dec 2023 09:20:44 +0000 Subject: [PATCH] Optimise getLinkDocuments --- packages/server/src/db/linkedRows/linkUtils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/server/src/db/linkedRows/linkUtils.ts b/packages/server/src/db/linkedRows/linkUtils.ts index faaf9c1f21..20f752407f 100644 --- a/packages/server/src/db/linkedRows/linkUtils.ts +++ b/packages/server/src/db/linkedRows/linkUtils.ts @@ -56,7 +56,7 @@ export async function getLinkDocuments(args: { try { let linkRows = (await db.query(getQueryIndex(ViewName.LINK), params)).rows // filter to get unique entries - const foundIds: string[] = [] + const foundIds = new Set() linkRows = linkRows.filter(link => { // make sure anything unique is the correct key if ( @@ -65,9 +65,9 @@ export async function getLinkDocuments(args: { ) { return false } - const unique = foundIds.indexOf(link.id) === -1 + const unique = !foundIds.has(link.id) if (unique) { - foundIds.push(link.id) + foundIds.add(link.id) } return unique })