Reduce allocations in VirtualFileInfo.Name #12550
Labels
Functionality:Restore
PerfWins
Priority:2
Issues for the current backlog.
Tenet:Performance
Performance issues
Type:Bug
Milestone
VisualFileInfo
is an implementation ofIFileInfo
used withMicrosoft.Extensions.FileSystemGlobbing
. It's used when matching files in the package to files listed in thecontentFiles
section of packagenuspec
files.The property is getting the filename from a path, but it does so with
PhysicalPath.Split('/').LastOrDefault();
. BothSplit
andLastOrDefault
cause allocations, plus the result is not cached and debugging shows the same instance can have theName
getter called multiple times.This code is used when generating the assets file when restoring a PackageReference project that uses a package that has
contentFiles/*
assets.The text was updated successfully, but these errors were encountered: