From bc8f2263570b41bafda4b1f4fe32c878b8fcd216 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Sat, 13 Jan 2024 01:23:13 +0000 Subject: [PATCH] Use set over array --- src/routes/Search.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/routes/Search.tsx b/src/routes/Search.tsx index 8344d485e..8c89a8b08 100644 --- a/src/routes/Search.tsx +++ b/src/routes/Search.tsx @@ -346,12 +346,12 @@ function GlobalSearch(props: { foundNpubs: (string | undefined)[]; }) { const hexpubs = createMemo(() => { - const hexpubs: string[] = []; + const hexpubs: Set = new Set(); for (const npub of props.foundNpubs) { hexpubFromNpub(npub) .then((h) => { if (h) { - hexpubs.push(h); + hexpubs.add(h); } }) .catch((e) => { @@ -361,7 +361,7 @@ function GlobalSearch(props: { return hexpubs; }); - async function searchFetcher(args: { value?: string; hexpubs?: string[] }) { + async function searchFetcher(args: { value?: string; hexpubs?: Set }) { try { // Handling case when value starts with "npub" if (args.value?.toLowerCase().startsWith("npub")) { @@ -377,7 +377,7 @@ function GlobalSearch(props: { // Handling case for other values (name, nip-05, whatever else primal searches) const contacts = await searchProfiles(args.value!.toLowerCase()); - return contacts.filter((c) => !args.hexpubs?.includes(c.hexpub)); + return contacts.filter((c) => !args.hexpubs?.has(c.hexpub)); } catch (e) { console.error(e); return [];