Skip to content

Conversation

@kamja44
Copy link

@kamja44 kamja44 commented Dec 8, 2025

Summary

Optimizes icon migration performance by replacing O(n²) array search with O(1) Map lookups.

Problem

The current implementation uses Object.values().find() for every imported icon, resulting in O(n²) time complexity. With large icon mappings (500+ icons), this becomes noticeably slow.

Solution

  • Build a reverse index map (sourceToTargetMap) once at the start
  • Use Map.get() for O(1) lookups instead of array searches
  • Reduces complexity from O(n×m) to O(n+m)

Performance Impact

Example: 50 imported icons, 500 total mappings

  • Before: 25,000 operations (O(n²))
  • After: 550 operations (O(n))
  • ~45x faster

Changes

  • Added sourceToTargetMap construction before processing imports
  • Replaced Object.values().find() with Map.get()
  • Removed TODO comment about O(n²) performance

Testing

  • Existing tests pass (no behavior changes)
  • No new tests needed (internal optimization only)

Checklist

  • Code follows project conventions
  • Commit message follows conventional commits
  • No breaking changes

Resolves TODO comment at line 164.

Replace Object.values().find() with pre-built Map for O(1) lookups.
Reduces time complexity from O(n²) to O(n).

Resolves TODO comment about O(n²) performance issue.
@vercel
Copy link
Contributor

vercel bot commented Dec 8, 2025

@kamja44 is attempting to deploy a commit to the shadcn-pro Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant