mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
[PR #1131] More test fixes and some perf changes #1566
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/adamhathcock/sharpcompress/pull/1131
State: closed
Merged: Yes
This pull request introduces several improvements and refactorings to asynchronous ZIP archive handling and Deflate decompression. The main changes include refactoring buffer management for memory efficiency, updating async reading APIs for consistency, and improving resource cleanup. These updates enhance performance, reduce allocations, and make the codebase easier to maintain.
Async ZIP reading and buffer management improvements
SeekableZipHeaderFactoryto useArrayPool<byte>for buffer allocation in async header seeking, reducing memory allocations and improving performance. Also, updated the header search logic to use spans for efficient data access. [1] [2]DirectoryEndHeader,DirectoryEntryHeader,LocalEntryHeader, andZip64DirectoryEndHeader. [1] [2] [3] [4]SkipAsyncmethod toAsyncBinaryReaderand replaced unnecessary buffer reads with skips in ZIP header parsing, improving efficiency. [1] [2]Deflate decompression memory optimization
byte[]to anIMemoryOwner<byte>fromMemoryPool<byte>, ensuring pooled buffer usage and proper disposal for reduced GC pressure and memory leaks. All array copy operations were updated to use spans. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]Resource cleanup and async disposal
DisposeAsyncinRarArchiveto support proper async resource cleanup, including disposal of unpacker resources.InflateBlocks.Free()to prevent memory leaks when decompressing data.These changes collectively improve performance, resource management, and maintainability of the archive and compression codebase.