private static void Uncompress(ReusableMemoryStream uncompressed, byte[] body, int offset, int length, CompressionCodec codec) { try { if (codec == CompressionCodec.Snappy) { #if NET_CORE throw new NotImplementedException(); #else uncompressed.SetLength(SnappyCodec.GetUncompressedLength(body, offset, length)); SnappyCodec.Uncompress(body, offset, length, uncompressed.GetBuffer(), 0); #endif } else // compression == CompressionCodec.Gzip { using (var compressed = new MemoryStream(body, offset, length, false)) { using (var gzip = new GZipStream(compressed, CompressionMode.Decompress)) { using (var tmp = uncompressed.Pool.Reserve()) { gzip.ReusableCopyTo(uncompressed, tmp); } } } } uncompressed.Position = 0; } catch (Exception ex) { throw new UncompressException("Invalid compressed data.", codec, ex); } }