Skip to content

Commit 571d032

Browse files
authored
Fix list capacity calculation in GetGraphItemAsync that is leading to list resizing based allocations (#7026)
1 parent 31c6e73 commit 571d032

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public async Task<GraphItem<RemoteResolveResult>> GetGraphItemAsync(
9797
}
9898

9999
// Create a new list that is big enough for the existing items plus any runtime dependencies
100-
List<LibraryDependency> dependencies = new(capacity: RuntimeDependencies?.Count ?? 0 + item.Data.Dependencies.Count);
100+
List<LibraryDependency> dependencies = new(capacity: (RuntimeDependencies?.Count ?? 0) + item.Data.Dependencies.Count);
101101

102102
// Loop through the defined dependencies, leaving out any pruned packages or runtime packages that replace them
103103
for (int i = 0; i < item.Data.Dependencies.Count; i++)

0 commit comments

Comments
 (0)