Use Already Defined Helper Functions

This commit is contained in:
7H3LaughingMan 2025-04-29 13:42:47 -05:00
parent fa6947e57d
commit 3d27e02ac1

View file

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.IO.Compression;
using System.Linq; using System.Linq;
using System.Xml; using System.Xml;
@ -76,8 +75,8 @@ public abstract partial class TmxReaderBase
var decompressed = compression.Value switch var decompressed = compression.Value switch
{ {
DataCompression.GZip => DecompressGZip(bytes), DataCompression.GZip => Helpers.DecompressGZip(bytes),
DataCompression.ZLib => DecompressZLib(bytes), DataCompression.ZLib => Helpers.DecompressZLib(bytes),
DataCompression.ZStd => throw new NotSupportedException("ZStd compression is not supported."), DataCompression.ZStd => throw new NotSupportedException("ZStd compression is not supported."),
_ => throw new XmlException("Invalid compression") _ => throw new XmlException("Invalid compression")
}; };
@ -105,16 +104,4 @@ public abstract partial class TmxReaderBase
} }
return finalValues.ToArray(); return finalValues.ToArray();
} }
internal static uint[] DecompressGZip(MemoryStream stream)
{
using var decompressedStream = new GZipStream(stream, CompressionMode.Decompress);
return ReadMemoryStreamAsInt32Array(decompressedStream);
}
internal static uint[] DecompressZLib(MemoryStream stream)
{
using var decompressedStream = new ZLibStream(stream, CompressionMode.Decompress);
return ReadMemoryStreamAsInt32Array(decompressedStream);
}
} }