Skip to content
Closed
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
4 changes: 4 additions & 0 deletions .Jules/bolt.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2025-06-27 - [Map Initialization Overhead]
**Learning:** Initializing Maps with `new Map(array.map(...))` creates unnecessary intermediate arrays, consuming memory and triggering garbage collection overhead, especially noticeable when dealing with many nodes.
**Action:** Use a `for...of` loop to directly `map.set()` elements rather than creating an intermediate array of tuples, especially in frequently executed or rendering paths.

## 2025-06-27 - [High-Frequency Array Allocation in Render Loops]
**Learning:** Using `flatMap().join()` on arrays in a React render cycle (like high-frequency ERD search filtering inside `useMemo`) creates severe Garbage Collection pressure and performance bottlenecks compared to direct string concatenation due to intermediate array allocations.
**Action:** Use direct string concatenation with `+=` inside loops for heavy filtering operations to prevent excessive GC loads.
18 changes: 6 additions & 12 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,13 @@ export default function App() {
const searchMatchedNodeIds = useMemo(() => {
if (!normalizedNodeSearch) return new Set<string>();
const matches = new Set<string>();
// ⚡ Bolt: Replace map/flatMap array allocation with direct string concatenation for high-frequency ERD search filtering to prevent severe GC pressure.
for (const node of nodes) {
const haystack = [
node.data.title,
node.data.comment ?? "",
...node.data.columns.flatMap((column) => [
column.column_name,
column.data_type,
column.column_comment ?? "",
]),
]
.join(" ")
.toLocaleLowerCase();
if (haystack.includes(normalizedNodeSearch)) {
let haystack = `${node.data.title} ${node.data.comment ?? ""}`;
for (const column of node.data.columns) {
haystack += ` ${column.column_name} ${column.data_type} ${column.column_comment ?? ""}`;
}
if (haystack.toLocaleLowerCase().includes(normalizedNodeSearch)) {
matches.add(node.id);
}
}
Expand Down
Loading