mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-10 21:22:11 +00:00
[PR #1131] [MERGED] More test fixes and some perf changes #1561
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?
📋 Pull Request Information
Original PR: https://github.com/adamhathcock/sharpcompress/pull/1131
Author: @adamhathcock
Created: 1/15/2026
Status: ✅ Merged
Merged: 1/15/2026
Merged by: @adamhathcock
Base:
master← Head:adam/async-again📝 Commits (9)
c1d240bFix more testsebfa16fmore test fixes84b5b5aadd more tests81a2060reduce memory usage on headers437271cchange byte[] to memory using pool38eec23rar byte[] better227fec6more poolingc55a383Merge remote-tracking branch 'origin/master' into adam/async-againec310c8merge fixes and fmt📊 Changes
24 files changed (+488 additions, -163 deletions)
View changed files
📝
src/SharpCompress/Archives/Rar/RarArchive.cs(+14 -0)📝
src/SharpCompress/Common/AsyncBinaryReader.cs(+12 -4)📝
src/SharpCompress/Common/Zip/Headers/DirectoryEndHeader.cs(+2 -1)📝
src/SharpCompress/Common/Zip/Headers/DirectoryEntryHeader.cs(+6 -4)📝
src/SharpCompress/Common/Zip/Headers/LocalEntryHeader.cs(+4 -2)📝
src/SharpCompress/Common/Zip/Headers/Zip64DirectoryEndHeader.cs(+4 -5)📝
src/SharpCompress/Common/Zip/SeekableZipHeaderFactory.cs(+25 -86)📝
src/SharpCompress/Common/Zip/ZipHeaderFactory.cs(+1 -1)📝
src/SharpCompress/Compressors/Deflate/Inflate.cs(+27 -17)📝
src/SharpCompress/Compressors/Rar/RarStream.cs(+1 -1)📝
src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs(+4 -9)📝
src/SharpCompress/IO/BufferedSubStream.cs(+6 -2)📝
src/SharpCompress/IO/SharpCompressStream.cs(+0 -2)➕
tests/SharpCompress.Test/Ace/AceReaderAsyncTests.cs(+145 -0)➕
tests/SharpCompress.Test/Arj/ArjReaderAsyncTests.cs(+176 -0)📝
tests/SharpCompress.Test/BZip2/BZip2StreamAsyncTests.cs(+9 -8)📝
tests/SharpCompress.Test/GZip/GZipReaderAsyncTests.cs(+7 -1)📝
tests/SharpCompress.Test/Rar/RarArchiveAsyncTests.cs(+4 -1)📝
tests/SharpCompress.Test/SevenZip/SevenZipArchiveAsyncTests.cs(+21 -10)📝
tests/SharpCompress.Test/Tar/TarArchiveAsyncTests.cs(+5 -3)...and 4 more files
📄 Description
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.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.