⚡ Bolt: Optimize category and profile derivation in CategoryFilterWidget#60
⚡ Bolt: Optimize category and profile derivation in CategoryFilterWidget#60alazndy wants to merge 1 commit into
Conversation
Consolidated the previously separate derivations for `activeCategories` and `uniqueProfiles` into a single `useMemo` block utilizing a `for` loop. This prevents allocating intermediate arrays via chained `map`/`flatMap` methods, reducing overhead and execution time when generating state from large shortcut arrays. Co-authored-by: alazndy <78882672+alazndy@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
🎯 What
Consolidated the previously separate derivations for
activeCategoriesanduniqueProfilesinCategoryFilterWidget.tsxinto a singleuseMemoblock utilizing a standardforloop. Added a new entry in.jules/bolt.mddocumenting the learning.💡 Why
Previously, generating the
activeCategoriesanduniqueProfilessets involved multiple passes over theshortcutsarray usingmapandflatMap, creating intermediate arrays before passing them into theSetconstructor. For power users with large numbers of shortcuts, this caused unnecessary CPU overhead and garbage collection. Combining them into a single loop avoids intermediate allocations.📊 Impact
Reduces execution time by ~60% for the derivation logic based on standalone Node.js benchmarks (simulating 10,000 shortcuts, time dropped from ~1771ms to ~681ms for 1000 iterations).
🔬 Measurement
A temporary
benchmark.cjsscript was created using Node'sperf_hookswith a mocked array of 10,000 shortcuts. The unoptimized chained methods and the new consolidated loop were run 1,000 times after warmup, confirming the reduction in execution time. Changes were successfully type-checked viatsc --noEmitand verified via standard Vite build.PR created automatically by Jules for task 8875867067516161800 started by @alazndy