Avoid repeated delegate allocations in FileStream.FlushAsync (dotnet/coreclr#8048)
authorJustin Van Patten <jvp@justinvp.com>
Thu, 10 Nov 2016 04:05:11 +0000 (20:05 -0800)
committerJan Kotas <jkotas@microsoft.com>
Thu, 10 Nov 2016 04:05:11 +0000 (20:05 -0800)
Avoid the `Action<object>` allocation on each invocation of
`FileStream.FlushAsync` on Windows. This change makes the Win32
implementation match Unix.

Commit migrated from https://github.com/dotnet/coreclr/commit/2d19d2e7d57deee034650a8cc078c4ad93ce03c8

src/coreclr/src/mscorlib/corefx/System/IO/FileStream.Win32.cs

index 8b9adb5..350d948 100644 (file)
@@ -1715,7 +1715,7 @@ namespace System.IO
             if (CanWrite)
             {
                 return Task.Factory.StartNew(
-                    state => FlushOSBuffer(),
+                    state => ((FileStream)state).FlushOSBuffer(),
                     this,
                     cancellationToken,
                     TaskCreationOptions.DenyChildAttach,