Skip to content
Draft
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
7 changes: 4 additions & 3 deletions src/routes/profile/DomainsTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@

function handleSort() {
domains.sort((a, b) => {
const [aVal, bVal] = [a[sort], b[sort]][
sortDirection === 'ascending' ? 'slice' : 'reverse'
]();
// Bolt optimization: Avoid creating and slicing/reversing arrays in sort comparator
// to reduce O(N log N) garbage collection overhead
const aVal = sortDirection === 'ascending' ? a[sort] : b[sort];
const bVal = sortDirection === 'ascending' ? b[sort] : a[sort];
if (typeof aVal === 'string' && typeof bVal === 'string') return aVal.localeCompare(bVal);
return Number(aVal) - Number(bVal);
});
Expand Down