Write up the collection adapters - #3362
Open
FrayxRulez wants to merge 1 commit into
Open
Conversation
SearchCollection and IncrementalCollectionView are two implementations of the same adapter, differing by one real feature - the search query driver - and duplicating everything else. Reading them after the crash fixed in #3361 turned up a list of defects in both, plus a few in MediaCollection, none of which is worth losing. Records what the adapters are for, who uses which, what is wrong with each, and a direction: converge on IncrementalCollectionView's per-index morph and leave SearchCollection owning only the query. Open decisions are listed as open, and the one performance claim that has not been measured says so. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
A
.mdat the repo root, alongside the other review docs. No code changes.Reading
SearchCollectionafter the crash fixed in #3361 turned into a read of the whole area,and the main finding is worth recording:
SearchCollectionandIncrementalCollectionViewaretwo implementations of the same adapter. They differ by one real feature — the search query
driver — and duplicate everything else.
IncrementalCollectionView.ReplaceSourceis the newerand cheaper transition (tail adjust, then per-index replace, skipping equal items);
SearchCollectiondoes the same job with an LCS diff on the thread pool, which is what #3361 wasabout.
The document covers:
replaced, because swapping
ItemsSourcerebuilds the whole plumbing andClear()still costsa Reset and every container. Close in spirit to
CollectionViewSource, except that setting thesource morphs in place instead of resetting.
ChatAffiliateViewModeluses
SearchCollectionbut never setsQuery, andProfileGiftsTabViewModelhas alreadymigrated — its
SearchCollectionline is sitting there commented out._loadinghas twowriters (the root of Snapshot the collections before diffing them off-thread #3361, and the snapshot only papers over it),
UpdateImplisasync void,source changes are dropped during a transition,
SearchCollection's mirror has noReplacecase while
IncrementalCollectionView's has noMove,HasMoreItemsis a getter with a sideeffect, and
MediaCollection.LoadMoreItemsAsyncshadows its owncountparameter so therequested count is silently ignored.
SearchCollectionkeeping its nameand public API but owning only the query.
The one performance claim in it — that the per-index morph beats the diff here — is reasoning
about notification counts, not a benchmark, and the document says so.
🤖 Generated with Claude Code