Skip to content
Closed
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
8 changes: 7 additions & 1 deletion components/schedule/ScheduleContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ export default function ScheduleContainer({ initialSchedule, year }: Readonly<Sc
return initialSchedule;
}

const filterSessions = (sessions: GridSession[]) => sessions.filter((s) => savedSessionIds.includes(s.id) || s.isServiceSession);
/*
* ⚑ Bolt: Convert array to Set for O(1) lookups instead of O(N) array includes
* Expected impact: Time complexity improves from O(N*M) to O(N+M)
* Measurement: Schedule renders faster when large numbers of sessions are saved
*/
const savedIdsSet = new Set(savedSessionIds);
const filterSessions = (sessions: GridSession[]) => sessions.filter((s) => savedIdsSet.has(s.id) || s.isServiceSession);
Comment on lines +23 to +29
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comment block is quite verbose and includes tool-specific branding ("⚑ Bolt"). While documenting the performance optimization is helpful, a more concise and standard comment is preferred for long-term maintainability.

    // Use a Set for O(1) lookups to improve filtering performance from O(N*M) to O(N+M)
    const savedIdsSet = new Set(savedSessionIds);
    const filterSessions = (sessions: GridSession[]) => sessions.filter((s) => savedIdsSet.has(s.id) || s.isServiceSession);


return initialSchedule.map((day) => ({
...day,
Expand Down
Loading