Skip to content

Commit 1a7536a

Browse files
authored
Set HashSet capacity in dependency resolver (#6884)
1 parent b5efdd1 commit 1a7536a

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

src/NuGet.Core/NuGet.Commands/RestoreCommand/DependencyGraphResolver.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,11 +1255,7 @@ .. chosenResolvedItem.Suppressions
12551255
if (isRootProject)
12561256
{
12571257

1258-
#if NETSTANDARD
1259-
directPackageReferences = new HashSet<LibraryDependencyIndex>();
1260-
#else
12611258
directPackageReferences = new HashSet<LibraryDependencyIndex>(capacity: chosenResolvedItem.Item.Data.Dependencies.Count);
1262-
#endif
12631259

12641260
for (int i = 0; i < chosenResolvedItem.Item.Data.Dependencies.Count; i++)
12651261
{
@@ -1293,7 +1289,7 @@ .. chosenResolvedItem.Suppressions
12931289
// Suppress this dependency if PrivateAssets is set to "All"
12941290
if (dependency.SuppressParent == LibraryIncludeFlags.All)
12951291
{
1296-
suppressions ??= new HashSet<LibraryDependencyIndex>();
1292+
suppressions ??= new HashSet<LibraryDependencyIndex>(capacity: chosenResolvedItem.Item.Data.Dependencies.Count - i);
12971293

12981294
suppressions.Add(chosenResolvedItemChildLibraryDependencyIndex);
12991295
}

0 commit comments

Comments
 (0)