Skip to content

Commit ca025fd

Browse files
committed
Removed redundant stream check
1 parent 5e8f102 commit ca025fd

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/DotNext.IO/IO/PoolingBufferedStream.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -674,13 +674,13 @@ public override IAsyncResult BeginRead(byte[] data, int offset, int count, Async
674674
public override Task FlushAsync(CancellationToken token)
675675
{
676676
Task task;
677-
if (writePosition > 0)
677+
if (stream is null)
678678
{
679-
task = WriteAndFlushAsync(token);
679+
task = DisposedTask;
680680
}
681-
else if (stream is null)
681+
else if (writePosition > 0)
682682
{
683-
task = DisposedTask;
683+
task = WriteAndFlushAsync(token);
684684
}
685685
else
686686
{
@@ -697,11 +697,10 @@ public override Task FlushAsync(CancellationToken token)
697697

698698
private async Task WriteAndFlushAsync(CancellationToken token)
699699
{
700+
Debug.Assert(stream is not null);
700701
Debug.Assert(writePosition > 0);
701702
Debug.Assert(buffer.Length > 0);
702703

703-
ThrowIfDisposed();
704-
705704
await stream.WriteAsync(WrittenMemory, token).ConfigureAwait(false);
706705
await stream.FlushAsync(token).ConfigureAwait(false);
707706

0 commit comments

Comments
 (0)