diff --git a/.jules/bolt.md b/.jules/bolt.md index 38d4b732..84ca3beb 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -41,3 +41,7 @@ ## 2025-02-15 - Replace Array.from(map.values()).map with a for...of loop **Learning:** Using `Array.from(map.values()).map(...)` creates an unnecessary intermediate array which wastes memory allocation and garbage collection time, particularly for frequently re-rendered components handling large collections. **Action:** Use a `for...of` loop over `map.values()` to iterate and push mapped elements directly into the final array for O(1) memory and avoiding intermediate array allocations. +## 2025-02-16 - Avoid intermediate arrays in React map/filter chains + +**Learning:** Using chained array methods like `Array.from().map(...)` or `array.filter(...).map(...)` inside React render cycles allocates unnecessary intermediate arrays, creating GC pressure. +**Action:** Replace `Array.from({ length: N }).map(...)` with `Array.from({ length: N }, ...)` to process items directly. Use `.reduce()` instead of `.filter().map()` to avoid intermediate array allocation. diff --git a/apps/desktop/src/App.tsx b/apps/desktop/src/App.tsx index 09f44be4..dcd39aeb 100644 --- a/apps/desktop/src/App.tsx +++ b/apps/desktop/src/App.tsx @@ -481,7 +481,8 @@ export function App() {