Skip to content

Commit

Permalink
Remove unnecessary spills from BufferedStream.ReadAsync (#55190)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub committed Jul 6, 2021
1 parent 7e43f8c commit d25af09
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken
// If the requested read is larger than buffer size, avoid the buffer and still use a single read:
if (buffer.Length >= _bufferSize)
{
return bytesAlreadySatisfied + await _stream.ReadAsync(buffer, cancellationToken).ConfigureAwait(false);
return await _stream.ReadAsync(buffer, cancellationToken).ConfigureAwait(false) + bytesAlreadySatisfied;
}

// Ok. We can fill the buffer:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ private async ValueTask<int> ReadAsyncSlowPath(Task semaphoreLockTask, Memory<by
// If the requested read is larger than buffer size, avoid the buffer and still use a single read:
if (buffer.Length >= _bufferSize)
{
return bytesAlreadySatisfied + await _strategy.ReadAsync(buffer, cancellationToken).ConfigureAwait(false);
return await _strategy.ReadAsync(buffer, cancellationToken).ConfigureAwait(false) + bytesAlreadySatisfied;
}

// Ok. We can fill the buffer:
Expand Down

0 comments on commit d25af09

Please sign in to comment.