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
3 changes: 3 additions & 0 deletions .Jules/bolt.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 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.
## 2024-07-20 - String Iteration Performance
**Learning:** For high-frequency string operations in the frontend (e.g., generating handle IDs for nodes/edges), avoid using `Array.from(string)` as it creates intermediate array allocations and increases garbage collection overhead.
**Action:** Use a `for...of` loop or standard string iteration to avoid intermediate allocations and reduce garbage collection pressure.
16 changes: 12 additions & 4 deletions frontend/src/erd/handleUtils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
export function sanitizeHandleId(columnName: string): string {
const encoded = Array.from(columnName, (char) => {
// Array.from only yields non-empty Unicode scalars, so codePointAt(0) is defined.
return char.codePointAt(0)!.toString(16).padStart(4, '0')
}).join('-')
// Optimize string generation to avoid intermediate array allocations
// from Array.from and .join('-') by using a direct string builder.
let encoded = ''
let isFirst = true
for (const char of columnName) {
if (isFirst) {
isFirst = false
} else {
encoded += '-'
}
encoded += char.codePointAt(0)!.toString(16).padStart(4, '0')
}

return `c-${encoded || 'empty'}`
}
Expand Down
Loading