Skip to content

Node.js based forum software built for the modern web

perf: use .some for better perf, no need to filter entire array

Barış Soner Uşaklı22962f498353
diff --git a/src/controllers/topics.js b/src/controllers/topics.js
index 982bd46862..c9af94546b 100644
--- a/src/controllers/topics.js
+++ b/src/controllers/topics.js
@@ -227,7 +227,7 @@ async function loadCrosspostPrivilege(req, excludeCid) {
cidsUserCanCrosspost = await privileges.categories.filterCids('topics:crosspost', cids, req.uid);
crosspostCache.set(`uid:${req.uid}`, cidsUserCanCrosspost);
}
- return cidsUserCanCrosspost.filter(cid => cid !== excludeCid).length > 0;
+ return cidsUserCanCrosspost.some(cid => cid !== excludeCid);
}
async function buildBreadcrumbs(topicData) {