Skip to content
This repository was archived by the owner on Jul 8, 2022. It is now read-only.

Commit 54160f5

Browse files
committed
Kotlin 1.4.30 + min/max JS IR performance circumvention + Deprecate KDynamic in favour of new .dyn
1 parent 3d90175 commit 54160f5

File tree

34 files changed

+734
-399
lines changed

34 files changed

+734
-399
lines changed

gradle.properties

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# sytleguide
22
kotlin.code.style=official
33

4-
# Kotlin 1.4.30-RC: https://github.com/korlibs/easy-kotlin-mpp-gradle-plugin
5-
easyPluginVersion=0.12.5
4+
# Kotlin 1.4.30: https://github.com/korlibs/easy-kotlin-mpp-gradle-plugin
5+
easyPluginVersion=0.13.0
66

77
# version
88
group=com.soywiz.korlibs.korio
@@ -12,10 +12,10 @@ version=2.0.0-SNAPSHOT
1212
coroutinesVersion=1.4.2
1313

1414
# korlibs
15-
klockVersion=2.0.5
16-
kdsVersion=2.0.5
17-
kmemVersion=2.0.5
18-
kryptoVersion=2.0.5
15+
klockVersion=2.0.6
16+
kdsVersion=2.0.6
17+
kmemVersion=2.0.6
18+
kryptoVersion=2.0.6
1919

2020
# bintray location
2121
project.bintray.org=korlibs

korio/src/androidMain/kotlin/com/soywiz/korio/dynamic/DynamicInternalAndroid.kt

Lines changed: 0 additions & 94 deletions
This file was deleted.

korio/src/androidMain/kotlin/com/soywiz/korio/file/std/VfsAndroid.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.content.Context
44
import com.soywiz.korio.android.androidContext
55
import com.soywiz.klock.*
66
import com.soywiz.korio.file.*
7+
import com.soywiz.korio.internal.*
78
import com.soywiz.korio.lang.Closeable
89
import com.soywiz.korio.stream.*
910
import com.soywiz.korio.util.*
@@ -93,7 +94,7 @@ class AndroidResourcesVfs(var context: Context?) : Vfs() {
9394
val temp = ByteArray(16 * 1024)
9495
var available = (range.endExclusiveClamped - range.start)
9596
while (available >= 0) {
96-
val read = fs.read(temp, 0, Math.min(temp.size.toLong(), available).toInt())
97+
val read = fs.read(temp, 0, min2(temp.size.toLong(), available).toInt())
9798
if (read <= 0) break
9899
out.write(temp, 0, read)
99100
available -= read
@@ -181,8 +182,8 @@ private class LocalVfsJvm : LocalVfsV2() {
181182
override suspend fun readRange(path: String, range: LongRange): ByteArray = executeIo {
182183
RandomAccessFile(resolveFile(path), "r").use { raf ->
183184
val fileLength = raf.length()
184-
val start = kotlin.math.min(range.start, fileLength)
185-
val end = kotlin.math.min(range.endInclusive, fileLength - 1) + 1
185+
val start = min2(range.start, fileLength)
186+
val end = min2(range.endInclusive, fileLength - 1) + 1
186187
val totalRead = (end - start).toInt()
187188
val out = ByteArray(totalRead)
188189
raf.seek(start)

korio/src/commonMain/kotlin/com/soywiz/korio/async/ChannelExt.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.soywiz.korio.async
22

33
import com.soywiz.kmem.*
4+
import com.soywiz.korio.internal.*
5+
import com.soywiz.korio.internal.min2
46
import com.soywiz.korio.stream.*
57
import kotlinx.coroutines.*
68
import kotlinx.coroutines.channels.*
@@ -47,7 +49,7 @@ fun ReceiveChannel<ByteArray>.toAsyncInputStream(): AsyncInputStream {
4749
currentPos = 0
4850
}
4951

50-
val toRead = min(currentAvailable, len)
52+
val toRead = min2(currentAvailable, len)
5153
arraycopy(currentData, currentPos, buffer, offset, toRead)
5254
currentPos += toRead
5355
return toRead

korio/src/commonMain/kotlin/com/soywiz/korio/compression/deflate/Deflate.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import com.soywiz.kmem.*
44
import com.soywiz.korio.compression.*
55
import com.soywiz.korio.compression.util.*
66
import com.soywiz.korio.experimental.*
7+
import com.soywiz.korio.internal.*
8+
import com.soywiz.korio.internal.min2
79
import com.soywiz.korio.stream.*
810
import kotlin.math.*
911

@@ -20,7 +22,7 @@ open class DeflatePortable(val windowBits: Int) : CompressionMethod {
2022
) {
2123
while (i.hasAvailable()) {
2224
val available = i.getAvailable()
23-
val chunkSize = min(available, 0xFFFFL).toInt()
25+
val chunkSize = min2(available, 0xFFFFL).toInt()
2426
o.write8(if (chunkSize >= available) 1 else 0)
2527
o.write16LE(chunkSize)
2628
o.write16LE(chunkSize.inv())

korio/src/commonMain/kotlin/com/soywiz/korio/compression/lzma/SevenZip.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
package com.soywiz.korio.compression.lzma
44

55
import com.soywiz.korio.experimental.*
6+
import com.soywiz.korio.internal.*
7+
import com.soywiz.korio.internal.max2
68
import com.soywiz.korio.stream.*
79
import com.soywiz.korio.util.checksum.*
810
import kotlin.math.*
@@ -533,8 +535,8 @@ object SevenZip {
533535
if (dictionarySize < 0) return false
534536
if (m_DictionarySize != dictionarySize) {
535537
m_DictionarySize = dictionarySize
536-
m_DictionarySizeCheck = max(m_DictionarySize, 1)
537-
m_OutWindow.create(max(m_DictionarySizeCheck, 1 shl 12))
538+
m_DictionarySizeCheck = max2(m_DictionarySize, 1)
539+
m_OutWindow.create(max2(m_DictionarySizeCheck, 1 shl 12))
538540
}
539541
return true
540542
}
@@ -1414,7 +1416,7 @@ object SevenZip {
14141416
}
14151417

14161418
var numAvailableBytesFull = _matchFinder!!.getNumAvailableBytes() + 1
1417-
numAvailableBytesFull = min(kNumOpts - 1 - cur, numAvailableBytesFull)
1419+
numAvailableBytesFull = min2(kNumOpts - 1 - cur, numAvailableBytesFull)
14181420
numAvailableBytes = numAvailableBytesFull
14191421

14201422
if (numAvailableBytes < 2)
@@ -1423,7 +1425,7 @@ object SevenZip {
14231425
numAvailableBytes = _numFastBytes
14241426
if (!nextIsChar && matchByte != currentByte) {
14251427
// try Literal + rep0
1426-
val t = min(numAvailableBytesFull - 1, _numFastBytes)
1428+
val t = min2(numAvailableBytesFull - 1, _numFastBytes)
14271429
val lenTest2 = _matchFinder!!.getMatchLen(0, reps[0], t)
14281430
if (lenTest2 >= 2) {
14291431
val state2 = LzmaBase.stateUpdateChar(state)
@@ -1483,7 +1485,7 @@ object SevenZip {
14831485

14841486
// if (_maxMode)
14851487
if (lenTest < numAvailableBytesFull) {
1486-
val t = min(numAvailableBytesFull - 1 - lenTest, _numFastBytes)
1488+
val t = min2(numAvailableBytesFull - 1 - lenTest, _numFastBytes)
14871489
val lenTest2 = _matchFinder!!.getMatchLen(lenTest, reps[repIndex], t)
14881490
if (lenTest2 >= 2) {
14891491
var state2 =
@@ -1572,7 +1574,7 @@ object SevenZip {
15721574

15731575
if (lenTest == _matchDistances[offs]) {
15741576
if (lenTest < numAvailableBytesFull) {
1575-
val t = min(numAvailableBytesFull - 1 - lenTest, _numFastBytes)
1577+
val t = min2(numAvailableBytesFull - 1 - lenTest, _numFastBytes)
15761578
val lenTest2 = _matchFinder!!.getMatchLen(lenTest, curBack, t)
15771579
if (lenTest2 >= 2) {
15781580
var state2 =
@@ -2202,7 +2204,7 @@ object SevenZip {
22022204
_cyclicBufferPos - delta + _cyclicBufferSize) shl 1
22032205

22042206
val pby1 = _bufferOffset + curMatch
2205-
var len = min(len0, len1)
2207+
var len = min2(len0, len1)
22062208
if (_bufferBase!![pby1 + len] == _bufferBase!![cur + len]) {
22072209
while (++len != lenLimit)
22082210
if (_bufferBase!![pby1 + len] != _bufferBase!![cur + len])
@@ -2291,7 +2293,7 @@ object SevenZip {
22912293
_cyclicBufferPos - delta + _cyclicBufferSize) shl 1
22922294

22932295
val pby1 = _bufferOffset + curMatch
2294-
var len = min(len0, len1)
2296+
var len = min2(len0, len1)
22952297
if (_bufferBase!![pby1 + len] == _bufferBase!![cur + len]) {
22962298
while (++len != lenLimit)
22972299
if (_bufferBase!![pby1 + len] != _bufferBase!![cur + len])

korio/src/commonMain/kotlin/com/soywiz/korio/compression/util/BitReader.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package com.soywiz.korio.compression.util
33
import com.soywiz.kds.*
44
import com.soywiz.kmem.*
55
import com.soywiz.korio.experimental.*
6+
import com.soywiz.korio.internal.*
7+
import com.soywiz.korio.internal.min2
68
import com.soywiz.korio.lang.*
79
import com.soywiz.korio.stream.*
810
import kotlin.math.*
@@ -38,7 +40,7 @@ open class BitReader(val s: AsyncInputStreamWithLength) : AsyncInputStreamWithLe
3840
private val tempBA = ByteArray(BIG_CHUNK_SIZE)
3941
suspend fun prepareBytesUpTo(expectedBytes: Int): BitReader {
4042
while (sbuffers.availableRead < expectedBytes) {
41-
val read = s.read(tempBA, 0, min(tempBA.size, expectedBytes))
43+
val read = s.read(tempBA, 0, min2(tempBA.size, expectedBytes))
4244
if (read <= 0) break // No more data
4345
sbuffers.write(tempBA, 0, read)
4446
}

korio/src/commonMain/kotlin/com/soywiz/korio/compression/zip/Zip.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import com.soywiz.kmem.extract
55
import com.soywiz.kmem.toIntClamp
66
import com.soywiz.kmem.unsigned
77
import com.soywiz.korio.file.*
8+
import com.soywiz.korio.internal.*
89
import com.soywiz.korio.internal.indexOf
10+
import com.soywiz.korio.internal.max2
911
import com.soywiz.korio.stream.*
1012
import com.soywiz.krypto.encoding.*
1113
import kotlin.math.max
@@ -37,9 +39,9 @@ class ZipFile private constructor(
3739
val fileLength = s.getLength()
3840

3941
for (chunkSize in listOf(0x16, 0x100, 0x1000, 0x10000)) {
40-
val pos = max(0L, fileLength - chunkSize)
42+
val pos = max2(0L, fileLength - chunkSize)
4143
s.setPosition(pos)
42-
val bytesLen = max(chunkSize, s.getAvailable().toIntClamp())
44+
val bytesLen = max2(chunkSize, s.getAvailable().toIntClamp())
4345
val ebytes = s.readBytesExact(bytesLen)
4446
endBytes = ebytes
4547
pk_endIndex = endBytes.indexOf(PK_END)

0 commit comments

Comments
 (0)