Reduce Unix enumeration allocations (dotnet/corefx#26942)
authorJeremy Kuhne <jeremy.kuhne@microsoft.com>
Thu, 8 Feb 2018 20:55:15 +0000 (12:55 -0800)
committerGitHub <noreply@github.com>
Thu, 8 Feb 2018 20:55:15 +0000 (12:55 -0800)
commit113d51c8f3e1942dbc75b844c1da42d8c4bdb08f
tree06c76ff60e6ae4caa41165a26412182279f7dae3
parent6253320d796d712d214da992cf2877c3e8771c6a
Reduce Unix enumeration allocations (dotnet/corefx#26942)

* Reduce Unix enumeration allocations

This change factors out the FileStatus access into a helper struct and adds overloads
for the stat imports  that allow passing a span.

The next steps:

- Handle errors manually
- Skip using safehandle
- Look for further opportunities around UTF-8/16 conversion

* Address feedback

Shuffle code around a bit in FileInfo for clarity. Also shift directory determination
to FileSystemEntry to avoid allocation on links.

Commit migrated from https://github.com/dotnet/corefx/commit/c64171e379090b372fe232ec3f27a57ae838406c
16 files changed:
src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Span.cs [new file with mode: 0644]
src/libraries/Common/src/System/IO/PathInternal.cs
src/libraries/Common/src/System/Text/ValueUtf8Converter.cs [new file with mode: 0644]
src/libraries/System.IO.FileSystem/System.IO.FileSystem.sln
src/libraries/System.IO.FileSystem/src/System.IO.FileSystem.csproj
src/libraries/System.IO.FileSystem/src/System/IO/DirectoryInfo.Unix.cs [new file with mode: 0644]
src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEntry.Unix.cs
src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Unix.cs
src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Windows.cs
src/libraries/System.IO.FileSystem/src/System/IO/FileInfo.Unix.cs [new file with mode: 0644]
src/libraries/System.IO.FileSystem/src/System/IO/FileStatus.Unix.cs [new file with mode: 0644]
src/libraries/System.IO.FileSystem/src/System/IO/FileSystemInfo.Unix.cs
src/libraries/System.IO.FileSystem/src/System/IO/FileSystemInfo.Win32.cs [deleted file]
src/libraries/System.IO.FileSystem/src/System/IO/FileSystemInfo.Windows.cs
src/libraries/System.IO.FileSystem/src/System/IO/FileSystemInfo.cs
src/libraries/System.IO.FileSystem/tests/Enumeration/SkipAttributeTests.netcoreapp.cs