From 1ffaf8526179145fd86ed4287993fa619df7d25d Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 30 Jun 2026 12:54:03 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Optimize=20array=20lookup=20for=20P?= =?UTF-8?q?R=20impact=20calculation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace O(N) array find() with O(1) Set lookup Co-authored-by: julesklord <801266+julesklord@users.noreply.github.com> --- src/lib/parser.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/parser.js b/src/lib/parser.js index 89e616d..37f3eb3 100644 --- a/src/lib/parser.js +++ b/src/lib/parser.js @@ -4586,9 +4586,12 @@ function calcPRRisk(prData, repoData) { var changedFiles = prData.files || []; var totalBlast = 0; var hotspots = []; + var repoFilePaths = new Set(); + if (repoData.files) { + repoData.files.forEach(function(df) { repoFilePaths.add(df.path); }); + } changedFiles.forEach(function(f) { - var existing = repoData.files.find(function(df) { return df.path === f.filename; }); - if (existing) { + if (repoFilePaths.has(f.filename)) { var blast = calcBlast(f.filename, repoData.connections, repoData.files); totalBlast += blast.count; if (blast.count > 5) hotspots.push({ file: f.filename, blast: blast.count });