Skip to content

Add support for decompresing data in ReadOnlySpan<byte> with Deflate algorithm #24622

@lukaskabrt

Description

@lukaskabrt

System.IO.Compression contains the DeflateStream class, that can decompress data from a stream. In case we have compressed data already loaded in a ReadOnlySpan<byte>, using DeflateStream might be little inefficient - we have to create a MemoryStream and this operation allocates a new array.

    function Decompress(ReadOnlySpan<byte> block) {
        using(var stream = new MemoryStream(block.ToArray())) {
            using(var deflateStream = new DeflateStream(stream, CompressionMode.Decompress)) {
                Data = ... read from deflateStream
            }
        }
   }

It would be great, if the Deflate algorithm is exposed in the way that supports processing data from ReadOnlySpan<byte>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions