Skip to content
Draft
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
Expand Up @@ -9,3 +9,7 @@

**Learning:** Using `on:keyup` for search input debouncing triggers unnecessary API calls on navigation keys (arrows, home, end) and misses changes from paste/cut. Svelte's reactive statements `$: debounce(value)` provide a robust, declarative way to trigger debouncing only when the value actually changes.
**Action:** Replace `on:keyup` handlers with reactive statements for input debouncing to improve performance and correctness.

## 2024-11-04 - Array Sorting Overhead
**Learning:** Destructuring and array methods like `[a, b][condition ? 'slice' : 'reverse']()` inside an `Array.prototype.sort()` callback introduces heavy Garbage Collection overhead, halving performance for large arrays.
**Action:** Always use scalar variable assignments and mathematical negations (`return condition ? cmp : -cmp;`) to implement descending order sorting.
15 changes: 10 additions & 5 deletions src/routes/profile/DomainsTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@

function handleSort() {
domains.sort((a, b) => {
const [aVal, bVal] = [a[sort], b[sort]][
sortDirection === 'ascending' ? 'slice' : 'reverse'
]();
if (typeof aVal === 'string' && typeof bVal === 'string') return aVal.localeCompare(bVal);
return Number(aVal) - Number(bVal);
// ⚑ Bolt: Removed array destructuring and slice/reverse to avoid excessive GC overhead during sorting
const aVal = a[sort];
const bVal = b[sort];
let cmp = 0;
if (typeof aVal === 'string' && typeof bVal === 'string') {
cmp = aVal.localeCompare(bVal);
} else {
cmp = Number(aVal) - Number(bVal);
}
return sortDirection === 'ascending' ? cmp : -cmp;
});
domains = domains;
}
Expand Down