Skip to content

Commit d8e33dd

Browse files
authored
Reduce allocation in GetContentFileGroup by providing accurate capacity for List (#7037)
1 parent 8e542b7 commit d8e33dd

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/NuGet.Core/NuGet.Commands/RestoreCommand/ContentFiles/ContentFileUtils.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ internal static List<LockFileContentFile> GetContentFileGroup(
7575
NuspecReader nuspec,
7676
List<ContentItemGroup> contentFileGroups)
7777
{
78-
var results = new List<LockFileContentFile>(contentFileGroups.Count);
7978
var rootFolderPathLength = ContentFilesFolderName.Length;
8079

8180
// Read the contentFiles section of the nuspec
@@ -148,6 +147,8 @@ internal static List<LockFileContentFile> GetContentFileGroup(
148147
}
149148
}
150149

150+
var results = new List<LockFileContentFile>(entryMappings.Count);
151+
151152
// Create lock file entries for each item in the contentFiles folder
152153
foreach ((var file, var entries) in entryMappings)
153154
{

0 commit comments

Comments
 (0)