From 9ec8a0c427e3b4c5e1158f6b52038b5248b7ac78 Mon Sep 17 00:00:00 2001 From: anyulled <100741+anyulled@users.noreply.github.com> Date: Wed, 29 Apr 2026 09:26:56 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Optimize=20array=20look?= =?UTF-8?q?ups=20in=20filters=20to=20use=20Sets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaced Array.includes() inside array.filter() with Set.has() in ScheduleContainer and useTalks to improve lookup time complexity from O(N*M) to O(N+M). Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- .jules/bolt.md | 5 +++++ components/schedule/ScheduleContainer.tsx | 8 +++++++- hooks/useTalks.ts | 8 +++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.jules/bolt.md b/.jules/bolt.md index d81fd70a..68424efa 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -17,3 +17,8 @@ **Learning:** When attempting to optimize an O(N^2) array spread operation (`[...existing, talk]`) inside a grouping loop in `groupTalksByTrack`, the purely functional/immutable constraint specified by the team (and the lack of `Map.groupBy` support in Node 20.x Jest environments) means that we must fall back to immutable reductions. **Action:** When constraints require strict immutability without mutation of objects, use `reduce` with object and array spreads (e.g., `{ ...acc, [key]: [...(acc[key] || []), item] }`) even if it introduces O(N^2) overhead for large arrays. Avoid using `push()` or modifying accumulators directly. Always run Prettier/formatting checks before merge to resolve CI failures. + +## 2026-04-29 - Formatting matters for comments + +**Learning:** When adding multi-line comments in `/* */` style in Next.js codebases, always ensure the text begins on a new line after the opening `/*` (e.g., `/*\n * text\n */`) to avoid 'Expected a linebreak after /*' and consecutive single-line comment errors. +**Action:** Validate comment structures via `npm run lint` closely when documenting Bolt optimizations. diff --git a/components/schedule/ScheduleContainer.tsx b/components/schedule/ScheduleContainer.tsx index 33d877a4..283c1537 100644 --- a/components/schedule/ScheduleContainer.tsx +++ b/components/schedule/ScheduleContainer.tsx @@ -20,7 +20,13 @@ export default function ScheduleContainer({ initialSchedule, year }: Readonly sessions.filter((s) => savedSessionIds.includes(s.id) || s.isServiceSession); + /* + * ⚡ Bolt: Optimize array lookup from O(N*M) to O(N+M) + * By converting the saved sessions array to a Set before filtering, + * we prevent O(N^2) time complexity when filtering large session lists + */ + const savedSessionIdsSet = new Set(savedSessionIds); + const filterSessions = (sessions: GridSession[]) => sessions.filter((s) => savedSessionIdsSet.has(s.id) || s.isServiceSession); return initialSchedule.map((day) => ({ ...day, diff --git a/hooks/useTalks.ts b/hooks/useTalks.ts index 5dc92f83..80848fe6 100644 --- a/hooks/useTalks.ts +++ b/hooks/useTalks.ts @@ -129,7 +129,13 @@ export const groupTalksByTrack = (talks: Talk[]): Map => { */ export const getTalkSpeakersWithDetails = async (year: string | number, speakerIds: string[]): Promise => { const speakers = await getSpeakers(year); - return speakers.filter((s) => speakerIds.includes(s.id)); + /* + * ⚡ Bolt: Optimize array lookup from O(N*M) to O(N+M) + * Converting speakerIds to a Set to prevent nested iterations + * when matching speakers against the main speaker list + */ + const speakerIdsSet = new Set(speakerIds); + return speakers.filter((s) => speakerIdsSet.has(s.id)); }; export const getRelatedTalksByTrack = async (year: string | number, track: string, excludeTalkId: string, limit: number = 5): Promise => { From 5d0bf5afafc0e0c77b4cd2fabb678688e8e46db4 Mon Sep 17 00:00:00 2001 From: anyulled <100741+anyulled@users.noreply.github.com> Date: Wed, 29 Apr 2026 09:35:53 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Optimize=20array=20look?= =?UTF-8?q?ups=20in=20filters=20to=20use=20Sets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaced Array.includes() inside array.filter() with Set.has() in ScheduleContainer and useTalks to improve lookup time complexity from O(N*M) to O(N+M). Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- .jules/bolt.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.jules/bolt.md b/.jules/bolt.md index 68424efa..3433fd72 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -20,5 +20,5 @@ ## 2026-04-29 - Formatting matters for comments -**Learning:** When adding multi-line comments in `/* */` style in Next.js codebases, always ensure the text begins on a new line after the opening `/*` (e.g., `/*\n * text\n */`) to avoid 'Expected a linebreak after /*' and consecutive single-line comment errors. +**Learning:** When adding multi-line comments in `/* */` style in Next.js codebases, always ensure the text begins on a new line after the opening `/*` (e.g., `/*\n * text\n */`) to avoid 'Expected a linebreak after /\*' and consecutive single-line comment errors. **Action:** Validate comment structures via `npm run lint` closely when documenting Bolt optimizations.