docs(DisjointSet): fix parameterless-ctor capacity claim - #292
Merged
marius-bughiu merged 1 commit intoJul 23, 2026
Conversation
The parameterless constructor forwards `capacity: 0`, which allocates empty backing arrays (Capacity == 0) — the DefaultCapacity of 4 only applies on the first Grow(). The doc claimed "a small default capacity," which is inaccurate. Reword to match the sibling Deque() doc: no pre-allocated capacity, first Add allocates. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Coverage
Files below 100% line coverage
|
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the XML documentation for DisjointSet<T>’s parameterless constructor to accurately describe its “allocate on first use” behavior, aligning the docs with the implementation and similar collection docs in this codebase.
Changes:
- Reworded
DisjointSet()constructor<summary>to state it starts with no pre-allocated capacity. - Clarified that the first
Addcall allocates the backing arrays.
Benchmarks2 regressions Highlights
Collections (384)
Hashers (100)
Same-runner A/B (sharded 6-way): main ( |
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.
What
The parameterless
DisjointSet()constructor's XML summary claimed it initializes the set "with a small default capacity." Reworded to state it pre-allocates nothing and that the firstAddallocates the backing arrays.Why
DisjointSet()forwards: this(0), and the capacity constructor treats0specially — it assignsArray.Empty<T>()/Array.Empty<int>()to all three backing arrays, soCapacityreturns0. TheDefaultCapacityof 4 only takes effect on the firstGrow(). The old wording implied storage was pre-sized at construction, which is inaccurate. The new wording mirrors the siblingDeque()constructor doc, which already documents this "allocate on first use" behavior correctly.Doc-only change; no behavioral impact.
Test plan
dotnet build— succeeds, 0 warnings / 0 errors