From 7ea4dde2fcca7759780ec0379c1449126cfeacce Mon Sep 17 00:00:00 2001 From: ArchLeaders Date: Sun, 14 Apr 2024 15:21:25 -0700 Subject: [PATCH] Add GetDecompressedSize method --- src/CsYaz0/Yaz0.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/CsYaz0/Yaz0.cs b/src/CsYaz0/Yaz0.cs index a854c78..faf2d9d 100644 --- a/src/CsYaz0/Yaz0.cs +++ b/src/CsYaz0/Yaz0.cs @@ -15,10 +15,14 @@ public static DataMarshal Compress(ReadOnlySpan src, uint alignment = 0, i } } + public static int GetDecompressedSize(ReadOnlySpan data) + { + return BinaryPrimitives.ReverseEndianness(MemoryMarshal.Read(data[4..8])); + } + public static byte[] Decompress(ReadOnlySpan data) { - uint bufferSize = BinaryPrimitives.ReverseEndianness(MemoryMarshal.Read(data[4..8])); - byte[] result = new byte[bufferSize]; + byte[] result = new byte[GetDecompressedSize(data)]; Decompress(data, result); return result; }