Skip to content

Commit

Permalink
Removed redundant stream check
Browse files Browse the repository at this point in the history
  • Loading branch information
sakno committed Jan 23, 2025
1 parent 5e8f102 commit ca025fd
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/DotNext.IO/IO/PoolingBufferedStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -674,13 +674,13 @@ public override IAsyncResult BeginRead(byte[] data, int offset, int count, Async
public override Task FlushAsync(CancellationToken token)
{
Task task;
if (writePosition > 0)
if (stream is null)
{
task = WriteAndFlushAsync(token);
task = DisposedTask;
}
else if (stream is null)
else if (writePosition > 0)
{
task = DisposedTask;
task = WriteAndFlushAsync(token);
}
else
{
Expand All @@ -697,11 +697,10 @@ public override Task FlushAsync(CancellationToken token)

private async Task WriteAndFlushAsync(CancellationToken token)
{
Debug.Assert(stream is not null);
Debug.Assert(writePosition > 0);
Debug.Assert(buffer.Length > 0);

ThrowIfDisposed();

await stream.WriteAsync(WrittenMemory, token).ConfigureAwait(false);
await stream.FlushAsync(token).ConfigureAwait(false);

Expand Down

0 comments on commit ca025fd

Please sign in to comment.