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
Expand Up @@ -77,3 +77,6 @@ Optimized metric route processing to O(N) by creating a mapping of routes direct
## 2024-07-13 - [Optimize Export Dictionary FK lookups]
**Learning:** Found O(N * C * E) performance bottleneck in ERD export dictionaries due to repeated array searching with `edges.some()` inside a nested loop over nodes and columns.
**Action:** Replace repeated linear array scans for edges by precomputing O(1) Set lookups of foreign key column handles per node before looping.
## 2024-08-24 - Avoid Array.from for short string iteration in hot paths
**Learning:** Using `Array.from` for string iteration causes intermediate array allocations, increasing garbage collection pressure when called repeatedly in hot paths like ERD graph handle generation.
**Action:** Replace `Array.from` with `for...of` loops in frequently executed functions to avoid unnecessary array allocations and reduce GC pauses.
15 changes: 10 additions & 5 deletions frontend/src/erd/handleUtils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
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('-')
if (!columnName) return 'c-empty'

return `c-${encoded || 'empty'}`
let encoded = ''
let isFirst = true
for (const char of columnName) {
if (!isFirst) encoded += '-'
encoded += char.codePointAt(0)!.toString(16).padStart(4, '0')
isFirst = false
}

return `c-${encoded}`
}
Comment on lines 1 to 13

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Handle-ID refactor is behavior-preserving

The for...of loop emits the same hyphen-joined hex as the prior Array.from(...).join('-'), and empty input returns c-empty, matching the old encoded || 'empty' fallback.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


export function sourceColumnHandleId(columnName: string): string {
Expand Down
Loading