diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/objects/dataStreams/DhDataInputStream.java b/core/src/main/java/com/seibel/distanthorizons/core/util/objects/dataStreams/DhDataInputStream.java index f5359e213..d6fe0c941 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/util/objects/dataStreams/DhDataInputStream.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/util/objects/dataStreams/DhDataInputStream.java @@ -61,7 +61,8 @@ public class DhDataInputStream extends DataInputStream ByteArrayInputStream byteArrayInputStream; if (compressionMode == EDhApiDataCompressionMode.Z_STD_BLOCK) { - byteArrayInputStream = new ByteArrayInputStream(PooledZstdDecompressor.decompressFrame(byteArray, checkout)); + ByteArrayList pooledByteArrayList = PooledZstdDecompressor.decompressFrame(byteArray, checkout); + byteArrayInputStream = new ByteArrayInputStream(pooledByteArrayList.elements(), 0, pooledByteArrayList.size()); } else { diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/objects/dataStreams/PooledZstdDecompressor.java b/core/src/main/java/com/seibel/distanthorizons/core/util/objects/dataStreams/PooledZstdDecompressor.java index 2636500a8..5af468a70 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/util/objects/dataStreams/PooledZstdDecompressor.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/util/objects/dataStreams/PooledZstdDecompressor.java @@ -12,7 +12,7 @@ public class PooledZstdDecompressor * Replaces {@link Zstd#decompress} so we can use a pooled byte array * which significantly reduces GC pressure. */ - public static byte[] decompressFrame(byte[] src, PhantomArrayListCheckout checkout) throws ZstdException + public static ByteArrayList decompressFrame(byte[] src, PhantomArrayListCheckout checkout) throws ZstdException { int compressedSize = (int) Zstd.findFrameCompressedSize(src, 0); int contentSize = (int) Zstd.getFrameContentSize(src, 0, compressedSize); @@ -30,7 +30,7 @@ public class PooledZstdDecompressor ByteArrayList destination = checkout.getByteArray(0, contentSize); return decompress(src, compressedSize, contentSize, destination); } - private static byte[] decompress(byte[] src, int srcSize, int originalSize, ByteArrayList destination) throws ZstdException + private static ByteArrayList decompress(byte[] src, int srcSize, int originalSize, ByteArrayList destination) throws ZstdException { if (originalSize < 0) { @@ -49,7 +49,7 @@ public class PooledZstdDecompressor destination.size(size); // this assumes the size will only be smaller than the expected } - return destination.elements(); + return destination; } }