From e634c728f0835b6f4155cb0b57b3fa500644eae8 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Sun, 20 Mar 2022 15:13:30 +0800 Subject: [PATCH] Don't run filters unless necessary The loop was executed over the entire `tileUris` regardless of whether `excludeUris` existed. --- ui/component/claimList/view.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ui/component/claimList/view.jsx b/ui/component/claimList/view.jsx index d9d645f8e..ada4757fc 100644 --- a/ui/component/claimList/view.jsx +++ b/ui/component/claimList/view.jsx @@ -114,14 +114,18 @@ export default function ClaimList(props: Props) { const urisLength = (uris && uris.length) || 0; let tileUris = (prefixUris || []).concat(uris || []); - tileUris = tileUris.filter((uri) => !excludeUris.includes(uri)); + + if (excludeUris && excludeUris.length) { + tileUris = tileUris.filter((uri) => !excludeUris.includes(uri)); + } + if (prefixUris && prefixUris.length) tileUris.splice(prefixUris.length * -1, prefixUris.length); const totalLength = tileUris.length; if (maxClaimRender) tileUris = tileUris.slice(0, maxClaimRender); - let sortedUris = (urisLength > 0 && (currentSort === SORT_NEW ? tileUris : tileUris.slice().reverse())) || []; + const sortedUris = (urisLength > 0 && (currentSort === SORT_NEW ? tileUris : tileUris.slice().reverse())) || []; React.useEffect(() => { if (typeof loadedCallback === 'function') loadedCallback(totalLength);