From a9568bc0552ef0cac57c24da453af4033e692bcb Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 6 Dec 2023 21:15:29 -0300 Subject: [PATCH] reporter: fix bad logic --- scripts/generateReport.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/generateReport.ts b/scripts/generateReport.ts index a75a5985f..54db96e66 100644 --- a/scripts/generateReport.ts +++ b/scripts/generateReport.ts @@ -335,15 +335,15 @@ function runTime(token: string) { await (wreq as any).el(sym); delete Object.prototype[sym]; - const validChunksEntryPoints = [] as string[]; - const validChunks = [] as string[]; - const invalidChunks = [] as string[]; + const validChunksEntryPoints = new Set(); + const validChunks = new Set(); + const invalidChunks = new Set(); if (!chunks) throw new Error("Failed to get chunks"); - chunksLoop: for (const entryPoint in chunks) { const chunkIds = chunks[entryPoint]; + let invalidEntryPoint = false; for (const id of chunkIds) { if (!wreq.u(id)) continue; @@ -353,14 +353,16 @@ function runTime(token: string) { .then(t => t.includes(".module.wasm") || !t.includes("(this.webpackChunkdiscord_app=this.webpackChunkdiscord_app||[]).push")); if (isWasm) { - invalidChunks.push(id); - continue chunksLoop; + invalidChunks.add(id); + invalidEntryPoint = true; + continue; } - validChunks.push(id); + validChunks.add(id); } - validChunksEntryPoints.push(entryPoint); + if (!invalidEntryPoint) + validChunksEntryPoints.add(entryPoint); } for (const entryPoint of validChunksEntryPoints) { @@ -373,7 +375,7 @@ function runTime(token: string) { const allChunks = Function("return " + (wreq.u.toString().match(/(?<=\()\{.+?\}/s)?.[0] ?? "null"))() as Record | null; if (!allChunks) throw new Error("Failed to get all chunks"); const chunksLeft = Object.keys(allChunks).filter(id => { - return !(validChunks.includes(id) || invalidChunks.includes(id)); + return !(validChunks.has(id) || invalidChunks.has(id)); }); for (const id of chunksLeft) {