⚡ Bolt: Optimize batch updates to @Published view models#95
⚡ Bolt: Optimize batch updates to @Published view models#95
Conversation
Replaced `for` loop mutations in `CacheoutViewModel` with functional `.map` assignments to batch `@Published` updates. This changes the O(n) UI invalidations per operation into O(1), improving SwiftUI responsiveness when interacting with large result lists. Co-authored-by: acebytes <2820910+acebytes@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: Replaced
forloop mutations on@Publishedarrays (scanResultsandnodeModulesItems) with functional.mapoperations that reassign the entire array at once.🎯 Why: In SwiftUI, mutating an element of an
@Publishedarray inside a loop triggers theobjectWillChangenotification on every single iteration. For lists with many items, actions like "Select All" caused an O(n) avalanche of UI redraws, locking up the main thread.📊 Impact: Reduces UI invalidation events from O(N) to O(1) for all batch selection operations, significantly improving perceived UI responsiveness.
🔬 Measurement: Can be measured using Instruments (SwiftUI template) while clicking "Select All" on a fully populated node_modules list; the number of View redraws will be drastically lower.
PR created automatically by Jules for task 4753550879094667186 started by @acebytes