diff --git a/.jules/bolt.md b/.jules/bolt.md index a6d28e4e..94ded181 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -32,3 +32,7 @@ ## 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-07-09 - [Early Loop Termination for Score Search] +**Learning:** In optimization passes or matching passes that score candidates (like `grabNextAvailablePlayer` in group creation), the algorithm can find a "perfect" or optimal zero-penalty match (`score === 0`). Failing to break out of the loop at this point leads to unnecessary iterations over the entire remaining candidate pool, wasting CPU cycles on a search that cannot mathematically yield a better result. +**Action:** When scanning collections for a minimum/maximum score, always add an early loop termination condition (`break`) if an absolute optimal limit (like `bestScore === 0`) is reached. diff --git a/activity/tests/__screenshots__/components.spec.ts/group-slide.png b/activity/tests/__screenshots__/components.spec.ts/group-slide.png index 90eaa5f1..c88a9418 100644 Binary files a/activity/tests/__screenshots__/components.spec.ts/group-slide.png and b/activity/tests/__screenshots__/components.spec.ts/group-slide.png differ diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 9937707b..d707780d 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -28,6 +28,7 @@ export { shortestPath, parseSeasonPairs, } from './seasonPairs.js'; +export type { SeasonPairs } from './seasonPairs.js'; export { generateInviteCommand } from './inviteCommand.js'; diff --git a/packages/shared/src/parallelGroupCreator.ts b/packages/shared/src/parallelGroupCreator.ts index c015ff0d..f915c85a 100644 --- a/packages/shared/src/parallelGroupCreator.ts +++ b/packages/shared/src/parallelGroupCreator.ts @@ -446,6 +446,9 @@ export function createMythicPlusGroups( if (score < bestScore) { bestScore = score; bestPlayer = player; + + // ⚡ Bolt Opt: Absolute optimal score reached, skip checking remaining players + if (bestScore === 0) break; } }