Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sakno committed Jan 23, 2025
1 parent 2113e53 commit 5e8f102
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions src/DotNext.IO/IO/PoolingBufferedStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,27 +213,13 @@ public void Write()
/// <returns>The task representing asynchronous execution of the operation.</returns>
/// <exception cref="OperationCanceledException">The operation has been canceled.</exception>
/// <exception cref="ObjectDisposedException">The stream is disposed.</exception>
public ValueTask WriteAsync(CancellationToken token = default)
public async ValueTask WriteAsync(CancellationToken token = default)
{
ValueTask task;
if (stream is null)
{
task = new(DisposedTask);
}
else if (stream.CanWrite)
{
task = WriteCoreAsync(token);
}
else
{
task = ValueTask.FromException(new NotSupportedException());
}

return task;
}
AssertState();
ThrowIfDisposed();
if (!stream.CanWrite)
throw new NotSupportedException();

private async ValueTask WriteCoreAsync(CancellationToken token)
{
await WriteCoreAsync(out var isWritten, token).ConfigureAwait(false);
if (isWritten)
Reset();
Expand Down

0 comments on commit 5e8f102

Please sign in to comment.