From 799277b38657f4c22f3fbee5b9d5a48a18ece0fb Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 29 Jan 2022 22:17:08 +0000 Subject: [PATCH] Simplify JagexGzipOutputStream Deflater already tracks the size of the input. Signed-off-by: Graham --- .../org/openrs2/compress/gzip/JagexGzipOutputStream.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/compress/src/main/kotlin/org/openrs2/compress/gzip/JagexGzipOutputStream.kt b/compress/src/main/kotlin/org/openrs2/compress/gzip/JagexGzipOutputStream.kt index 5265a3ec..0dc5dfb2 100644 --- a/compress/src/main/kotlin/org/openrs2/compress/gzip/JagexGzipOutputStream.kt +++ b/compress/src/main/kotlin/org/openrs2/compress/gzip/JagexGzipOutputStream.kt @@ -12,7 +12,6 @@ public class JagexGzipOutputStream( private val deflater = Deflater(Deflater.DEFAULT_COMPRESSION, true) private val buffer = ByteArray(4096) private val checksum = CRC32() - private var size = 0 private var closed = false init { @@ -32,8 +31,6 @@ public class JagexGzipOutputStream( override fun write(b: ByteArray, off: Int, len: Int) { checksum.update(b, off, len) - size += len - deflater.setInput(b, off, len) while (!deflater.needsInput()) { @@ -58,7 +55,7 @@ public class JagexGzipOutputStream( val dataOutput = LittleEndianDataOutputStream(output) dataOutput.writeInt(checksum.value.toInt()) - dataOutput.writeInt(size) + dataOutput.writeInt(deflater.totalIn) deflater.end() output.close()