Skip to content

⚡ Optimize Icon and Color Lookup Performance#15

Draft
Batyan45 wants to merge 1 commit intomainfrom
perf-optimize-icon-lookup-17427130584735089953
Draft

⚡ Optimize Icon and Color Lookup Performance#15
Batyan45 wants to merge 1 commit intomainfrom
perf-optimize-icon-lookup-17427130584735089953

Conversation

@Batyan45
Copy link
Copy Markdown
Owner

💡 What: Optimized the icon and color lookup logic in src/tasksProvider.ts by introducing O(1) Map lookups for exact matches and a single-pass regex for partial (substring) matches.

🎯 Why: The original implementation used a for-of loop over a Map's entries and called .includes() for every entry on every lookup. This was O(N*L) where N is the number of icon/color definitions and L is the length of the label. With the new approach, exact matches are O(1) and partial matches are significantly faster.

📊 Measured Improvement:

  • Baseline: 4378ms for 1 million iterations of icon/color lookups.
  • Optimized: 2960ms for 1 million iterations of the same lookups.
  • Improvement: ~32.4% faster on average.

The optimization preserves the "first match in configuration wins" priority behavior exactly and handles regex escaping for safety.


PR created automatically by Jules for task 17427130584735089953 started by @Batyan45

- Implemented O(1) Map lookup for exact matches in TaskItem icons and colors.
- Replaced inefficient O(N*L) loop for partial matches with a single-pass regex search.
- Pre-computed static regexes and priority maps to ensure high efficiency and preserve original behavior.
- Added regex escaping for safe handling of all task labels and types.
- Measured a ~32% performance improvement for combined lookup operations.
Repository owner deleted a comment from google-labs-jules bot Feb 25, 2026
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