Low hanging allocation fruit (#9796)

- We were allocating a Task<int> for every read, return a ValueTask<int> for the cases where reads complete synchronously.
This commit is contained in:
David Fowler 2019-04-28 19:02:01 -07:00 committed by Justin Kotalik
parent e22702891d
commit cc8af6d2c4
1 changed files with 2 additions and 2 deletions

View File

@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Server.IIS.Core
/// <param name="memory"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
internal async Task<int> ReadAsync(Memory<byte> memory, CancellationToken cancellationToken)
internal async ValueTask<int> ReadAsync(Memory<byte> memory, CancellationToken cancellationToken)
{
if (!_hasRequestReadingStarted)
{
@ -155,7 +155,7 @@ namespace Microsoft.AspNetCore.Server.IIS.Core
break;
}
flush = flush | result.IsCanceled;
flush |= result.IsCanceled;
if (flush)
{