Repository navigation
Conversation
mailbox_entries_with_counts ran a linear badge scan per sidebar entry on every metadata refresh (O(entries x accounts)). Build the account index once; first row wins, preserving the previous linear-search semantics.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mailbox_entries_with_counts(src/mail.rs) ran a linear scan over the per-account badge rows for every sidebar entry, on every metadata refresh — O(entries × accounts) each time. This builds the account index once (HashMapwithentry().or_insert, so the first row wins exactly like the previous linear search) and turns each lookup into O(1).Change
mailbox_entries_with_counts; no signature, type, or behaviour change.User-visible effects
None intended — identical sidebar counts, computed with fewer steps. Slightly cheaper sidebar refreshes on metadata updates, most noticeable with several accounts.
Tests
mailbox_entries_preserve_unicode_hierarchy_and_stable_idsand thesrc/mail.rssuite) exercises the changed function; relying on CI (cargo fmt --check,clippy,cargo test) as the gate.cargo/rustc), against a byte-verified copy ofmain(src/mail.rsblob09cd40f, matched viagit hash-objectbefore patching).Notes
src/mail.rs, so a trivial rebase may be needed at merge time — happy to do it on request.AGPL-3.0-only, with no credentials, mailbox data, or third-party material included.