Skip to content

Commit 06621fa

Browse files
committed
const
1 parent 45316dd commit 06621fa

File tree

1 file changed

+9
-3
lines changed
  • runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/compression

1 file changed

+9
-3
lines changed

runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/compression/GzipCompressor.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import aws.sdk.kotlin.crt.Closeable
88
import kotlinx.cinterop.*
99
import platform.zlib.*
1010

11+
private const val DEFAULT_WINDOW_BITS = 15 // Default window bits
12+
private const val WINDOW_BITS_GZIP_OFFSET = 16 // Gzip offset for window bits
13+
private const val MEM_LEVEL = 8 // Default memory level
14+
1115
/**
1216
* Streaming-style gzip compressor, implemented using zlib bindings
1317
*/
@@ -30,8 +34,8 @@ internal class GzipCompressor : Closeable {
3034
stream.ptr,
3135
Z_BEST_COMPRESSION,
3236
Z_DEFLATED,
33-
15 + 16, // Default windows bits (15) plus 16 for gzip encoding
34-
8, // Default memory level
37+
DEFAULT_WINDOW_BITS + WINDOW_BITS_GZIP_OFFSET, // Default windows bits (15) plus 16 for gzip encoding
38+
MEM_LEVEL,
3539
Z_DEFAULT_STRATEGY,
3640
ZLIB_VERSION,
3741
sizeOf<z_stream>().toInt(),
@@ -112,7 +116,9 @@ internal class GzipCompressor : Closeable {
112116
}
113117

114118
override fun close() {
115-
if (isClosed) { return }
119+
if (isClosed) {
120+
return
121+
}
116122

117123
deflateEnd(stream.ptr)
118124
nativeHeap.free(stream.ptr)

0 commit comments

Comments
 (0)