Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-07-16 - [Early Loop Termination in Group Scoring]
**Learning:** Found a hot path in `parallelGroupCreator.ts` where we iterate over `availablePlayers` to find the one with the lowest historical pair count with current teammates. Once a player with a score of `0` is found, continuing the loop is unnecessary as `0` is the absolute optimal score (scores cannot be negative).
**Action:** When optimizing scoring loops or hot paths, utilize early loop termination (e.g., `break` when an absolute optimal condition like `bestScore === 0` is met) to skip unnecessary iterations and save CPU cycles.
1 change: 1 addition & 0 deletions packages/shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export {
topAffinityFor,
shortestPath,
parseSeasonPairs,
type SeasonPairs,
} from './seasonPairs.js';

export { generateInviteCommand } from './inviteCommand.js';
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/parallelGroupCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ export function createMythicPlusGroups(
if (score < bestScore) {
bestScore = score;
bestPlayer = player;
// ⚡ Bolt Opt: Early loop termination when absolute optimal score is found
if (bestScore === 0) break;
}
}

Expand Down
Loading