Skip to content

⚡ Bolt: [Performance Improvement] Prevent O(N) allocations and re-renders on missing state item deletions#378

Open
ClarusIubar wants to merge 1 commit into
mainfrom
bolt-optimize-array-filter-12753926019551412995
Open

⚡ Bolt: [Performance Improvement] Prevent O(N) allocations and re-renders on missing state item deletions#378
ClarusIubar wants to merge 1 commit into
mainfrom
bolt-optimize-array-filter-12753926019551412995

Conversation

@ClarusIubar

Copy link
Copy Markdown
Contributor

💡 What: Replaced unconditional .filter() operations with .findIndex() lookups when removing single items from React state arrays in src/store/notification-store/actions.ts and src/store/notification-store/helpers.ts. When an item is not found, the original array reference is returned to abort the update entirely.

🎯 Why: Calling .filter() always creates a brand new array, triggering O(N) memory allocations, garbage collection pressure, and, importantly, unnecessary React state reconciliations, even if the target item does not exist in the array. This happens frequently when deleting a resource that might be present in some state arrays but not others.

📊 Impact: Reduces O(N) memory allocations and eliminates unnecessary React component tree re-renders for missing targets, resulting in a tighter, more efficient state update cycle for deletions.

🔬 Measurement: Review src/store/notification-store/actions.ts and helpers.ts. Array object identities remain stable across deleteNotification dispatches if the item was already absent from the local view. The tests pass cleanly.


PR created automatically by Jules for task 12753926019551412995 started by @ClarusIubar

… state deletions

Avoids O(N) array allocation overhead and prevents unnecessary React rerenders when an element isn't found in state.

Co-authored-by: ClarusIubar <101549899+ClarusIubar@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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