From 997648e1741d0b2bf12c364d3f79af60e0fbb655 Mon Sep 17 00:00:00 2001 From: "Md. Touhidur Rahman" <46617994+touhidurrr@users.noreply.github.com> Date: Sun, 22 Dec 2024 14:05:03 +0600 Subject: [PATCH] Set Gzip compression level to `Deflater.BEST_COMPRESSION` (#12691) * set gzip compression level to Deflater.BEST_COMPRESSION * Update Gzip.kt * Update Gzip.kt * Update Gzip.kt --- core/src/com/unciv/ui/screens/savescreens/Gzip.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/ui/screens/savescreens/Gzip.kt b/core/src/com/unciv/ui/screens/savescreens/Gzip.kt index 07b4f46ca2..6f98f51a28 100644 --- a/core/src/com/unciv/ui/screens/savescreens/Gzip.kt +++ b/core/src/com/unciv/ui/screens/savescreens/Gzip.kt @@ -5,17 +5,23 @@ import java.io.BufferedReader import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream import java.io.InputStreamReader +import java.util.zip.Deflater import java.util.zip.GZIPInputStream import java.util.zip.GZIPOutputStream + object Gzip { fun zip(data: String): String = encode(compress(data)) - fun unzip(data: String): String = decompress(decode(data)) + fun unzip(data: String): String = decompress(decode(data)) private fun compress(data: String): ByteArray { val bos = ByteArrayOutputStream(data.length) - val gzip = GZIPOutputStream(bos) + val gzip = object : GZIPOutputStream(bos) { + init { + def.setLevel(Deflater.BEST_COMPRESSION) + } + } gzip.write(data.toByteArray()) gzip.close() val compressed = bos.toByteArray()