From 5e5701431d47a49a9f2a29ea289513e90a3eaec9 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 25 Jun 2026 07:25:46 +0000 Subject: [PATCH 1/2] perf(shared): Short-circuit scoring loop in group creation Added an early loop termination in `grabNextAvailablePlayer` when the best possible score (`0`) is found, avoiding unnecessary iterations and score calculations for the remaining players. --- .jules/bolt.md | 3 +++ packages/shared/src/parallelGroupCreator.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/.jules/bolt.md b/.jules/bolt.md index a6d28e4e..e4e21d62 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -32,3 +32,6 @@ ## 2024-05-18 - Replacing O(N) array search inside nested loops with O(1) object properties **Learning:** During test optimizations, filtering candidate lists (like available tanks or healers) inside a heavy iterative loop using O(N) array checks (e.g. `Array.some()`) creates a severe performance bottleneck. **Action:** When filtering or excluding object references inside hot paths, prefer using inherent O(1) boolean properties on the object itself rather than building and parsing sub-arrays to check role inclusion. +## 2026-06-25 - [Short-circuiting in Scoring Loops] +**Learning:** In the parallel group creation algorithm, the `grabNextAvailablePlayer` function exhaustively calculated the score for every available player, even if it had already found a player with a perfect score of 0. +**Action:** Utilize early loop termination (e.g., `if (bestScore === 0) break;`) to skip unnecessary iterations and save CPU cycles when an absolute optimal condition is met in scoring or search loops. diff --git a/packages/shared/src/parallelGroupCreator.ts b/packages/shared/src/parallelGroupCreator.ts index c015ff0d..8934203b 100644 --- a/packages/shared/src/parallelGroupCreator.ts +++ b/packages/shared/src/parallelGroupCreator.ts @@ -446,6 +446,7 @@ export function createMythicPlusGroups( if (score < bestScore) { bestScore = score; bestPlayer = player; + if (bestScore === 0) break; // ⚡ Bolt Opt: Short-circuit on best possible score } } From cad91b8bad34339a483ceef56de6ffad64503618 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 25 Jun 2026 07:32:50 +0000 Subject: [PATCH 2/2] perf(shared): Short-circuit scoring loop in group creation Added an early loop termination in `grabNextAvailablePlayer` when the best possible score (`0`) is found, avoiding unnecessary iterations and score calculations for the remaining players. --- packages/shared/src/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 9937707b..c0678d0e 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -49,6 +49,8 @@ export type { WoWGroupDict, } from './types.js'; +export type { SeasonPairs } from './seasonPairs.js'; + export { CHARACTER_CLASSES, toCharacterClass, toRole, toUtility } from './types.js'; export { todayPST } from './dateHelpers.js';