Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -220,21 +220,24 @@ async Task Core(CancellationToken cancellationToken)
{
Debug.Assert(_deflater != null && _buffer != null);

// Compress any bytes left:
await WriteDeflaterOutputAsync(cancellationToken).ConfigureAwait(false);

// Pull out any bytes left inside deflater:
bool flushSuccessful;
do
if (_wroteBytes)
{
int compressedBytes;
flushSuccessful = _deflater.Flush(_buffer, out compressedBytes);
if (flushSuccessful)
// Compress any bytes left:
await WriteDeflaterOutputAsync(cancellationToken).ConfigureAwait(false);

// Pull out any bytes left inside deflater:
bool flushSuccessful;
do
{
await _stream.WriteAsync(new ReadOnlyMemory<byte>(_buffer, 0, compressedBytes), cancellationToken).ConfigureAwait(false);
}
Debug.Assert(flushSuccessful == (compressedBytes > 0));
} while (flushSuccessful);
int compressedBytes;
flushSuccessful = _deflater.Flush(_buffer, out compressedBytes);
if (flushSuccessful)
{
await _stream.WriteAsync(new ReadOnlyMemory<byte>(_buffer, 0, compressedBytes), cancellationToken).ConfigureAwait(false);
}
Debug.Assert(flushSuccessful == (compressedBytes > 0));
} while (flushSuccessful);
}
Comment on lines +223 to +240
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The entire deflater flush block is indented one level deeper, but the comment on line 225 still says 'Compress any bytes left' which may be slightly misleading when _wroteBytes is false and no compression occurs. Consider updating the comment to clarify the conditional nature, such as '// Compress any bytes left if data was written:'

Copilot uses AI. Check for mistakes.

// Always flush on the underlying stream
await _stream.FlushAsync(cancellationToken).ConfigureAwait(false);
Expand Down
Loading