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 @@ -21,3 +21,6 @@
## 2024-07-10 - O(n) Single Pass Data Aggregation
**Learning:** Using chained array methods (e.g. `.map().filter()`, `.flatMap()`, and repeated `.filter()` over the same large list like `profiles`) leads to redundant O(n) passes over data and allocates unnecessary intermediate arrays. This blocks the main thread longer than necessary when calculating basic statistics like `uniqueCities`, `uniqueTechs`, or total counts.
**Action:** Consolidate statistical aggregations over large object arrays into a single O(n) `for` loop that updates multiple accumulators (like `Set` objects and primitive counters) in one pass, thereby improving performance and reducing memory overhead.
## 2024-03-24 - React Component State and List Derivation
**Learning:** In components with highly interactive state (like a button triggering a local state change), deriving and formatting large lists inside the render body without memoization causes redundant O(N) object allocations on every render.
**Action:** Always wrap data derivations (like mapping a raw dataset into UI-ready objects) inside a `useMemo` hook, ensuring the dependency array only includes variables that actually alter the list structure.
7 changes: 5 additions & 2 deletions src/pages/matching-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -508,10 +508,13 @@ function ProjetsTab({
}
}, [user, interested]);

const displayList: { project: Project; score?: number; reasons?: string[] }[] =
profile && projectMatches.length > 0
// ⚡ Bolt: Memoize displayList to prevent O(N) object allocations on every render
// (e.g. when 'interested' state changes after clicking the "Je suis intéressé" button).
const displayList: { project: Project; score?: number; reasons?: string[] }[] = useMemo(() => {
return profile && projectMatches.length > 0
? projectMatches.map((m) => ({ project: m.project, score: m.score, reasons: m.reasons }))
: projects.map((p) => ({ project: p }));
}, [profile, projectMatches, projects]);

const visible = displayList.slice(0, visibleCount);

Expand Down
Loading