Skip to content

perf(switch): reuse the list collector's ref scan for the preview comparison base - #3308

Merged
max-sixty merged 1 commit into
mainfrom
summary-tab-dim
Jun 29, 2026
Merged

max-sixty merged 1 commit into
mainfrom
summary-tab-dim

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Follow-up to #3305. That PR routed the picker's diff/summary preview panes through the upstream-aware comparison base, which is resolved from a RefSnapshot and memoized on the repo's RepoCache. But the preview path captured its own snapshot — a second git for-each-ref scan duplicating the one the wt list collector already runs a moment earlier.

This primes that memoized base from the collector's snapshot. resolve_comparison_base splits into a snapshot-taking core (comparison_base_from) shared by the lazy path and a new prime_comparison_base; the collector calls the latter once from the snapshot it already holds. The picker's preview panes run on a clone of the collector's Repository (shared Arc<RepoCache>) and wt list --full's summary column runs on it directly, so both read the primed base instead of re-scanning. The lazy capture remains as the fallback for any caller that previews without collecting first.

No behavior change — the base value and its staleness characteristics are identical; only the scan that resolves it is shared instead of repeated.

Testing: new prime_comparison_base_feeds_branch_diff_spec exercises the prime path and asserts it feeds branch_diff_spec the upstream-aware base; the existing branch-diff and summary tests cover the lazy path. Feature-gated clippy and the rustdoc -Dwarnings gate are clean.

This was written by Claude Code on behalf of max

…parison base

The diff/summary preview panes resolve their comparison base by capturing
their own RefSnapshot, duplicating the scan the list collector already runs.
Split the resolution into a snapshot-taking core and have the collector prime
the memoized base from its snapshot; the panes share the same Arc<RepoCache>,
so they reuse it instead of re-scanning. The lazy capture stays as the
fallback for callers that preview without collecting first.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 73b2e1e into main Jun 29, 2026
36 checks passed
@max-sixty
max-sixty deleted the summary-tab-dim branch June 29, 2026 03:01
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.

2 participants