-
Notifications
You must be signed in to change notification settings - Fork 265
Description
NuGet Product Used
MSBuild.exe, NuGet.exe, dotnet.exe
Product Version
17.14
Worked before?
No response
Impact
It bothers me. A fix would be nice
Repro Steps & Context
PRISM is showing that this is a top allocation bug
Warning: This is AI-generated content and may be inaccurate.
Brief description
Issue type: Collections — DO specify an up-front capacity if one is known
Description: On the hot leaf path in ResolveDependencyGraphItemsAsync, a HashSet named suppressions is lazily initialized without capacity. This set is populated within a loop over chosenResolvedItem.Item.Data.Dependencies, causing potential internal resizes and allocations. We can derive an appropriate initial capacity from chosenResolvedItem.Item.Data.Dependencies.Count and pass it at construction to reduce allocations on this hot path.
Proposed fix: Initialize the HashSet with capacity using chosenResolvedItem.Item.Data.Dependencies.Count when it is first created.