Skip to content

Conversation

@stephentoub
Copy link
Member

And simplify a few open-coded loops into span operations.

…y{Async}

And simplify a few open-coded loops into span operations.
Copilot AI review requested due to automatic review settings January 31, 2026 13:04
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @karelz, @dotnet/area-system-io-compression
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Reduce GC pressure and simplify inner-loop code paths in System.IO.Compression by reusing buffers from ArrayPool<byte> and replacing manual loops with span operations.

Changes:

  • Replace allocating range operations / intermediate arrays with pooled buffers when reading the Zip central directory (sync + async).
  • Fix an allocation-heavy path in ZipCentralDirectoryFileHeader.TryReadBlockAsync by collating into a pooled Memory<byte> rather than creating a new array.
  • Simplify repeated writes in InflaterManaged.DecodeDynamicBlockHeader using Span.Fill / Span.Clear.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.Async.cs Uses a pooled buffer to collate dynamic header data without extra array allocations.
src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchive.cs Central directory read buffer is rented from ArrayPool<byte> instead of allocating a new array per read.
src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchive.Async.cs Async central directory parsing avoids range-operator array allocations by using ReadOnlyMemory<byte> slices over pooled buffers.
src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateManaged/InflaterManaged.cs Replaces small write loops with span-based fill/clear operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant