Skip to content
Open
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
@@ -0,0 +1,3 @@
## 2026-05-11 - [IconifyIcon O(N) Lookup Optimization]
**Learning:** The custom `IconifyIcon` component uses an O(N) iteration over multiple large `@iconify-json` static icon sets to support offline prefix-less icon lookups. This lookup runs on every render, which is a significant bottleneck given the component is used hundreds of times across the application.
**Action:** Implement a simple memoization cache (e.g. `Map`) for `iconData` results to prevent redundant O(N) JSON tree iterations and `getIconData` calls during React re-renders.
25 changes: 21 additions & 4 deletions client/src/components/base/IconifyIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,35 @@ const iconSets: Record<string, IconifyJSON> = {
"mdi-light": mdiLightIcons,
};

const iconDataCache = new Map<string, any>();

const iconData = (icon: string) => {
if (iconDataCache.has(icon)) {
return iconDataCache.get(icon);
}

const [prefix, name] = icon.includes(":") ? icon.split(":") : ["", icon];

let result;
if (prefix && iconSets[prefix]) {
const data = getIconData(iconSets[prefix], name);
if (data) return data;
if (data) {
result = data;
}
}

for (const [_, icons] of Object.entries(iconSets)) {
const data = getIconData(icons, name);
if (data) return data;
if (!result) {
for (const [_, icons] of Object.entries(iconSets)) {
const data = getIconData(icons, name);
if (data) {
result = data;
break;
}
}
}

iconDataCache.set(icon, result);
return result;
};

const IconifyIcon = ({
Expand Down