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

Commit

Permalink
Kotlin 1.4.30 + min/max JS IR performance circumvention + Deprecate K…
Browse files Browse the repository at this point in the history
…Dynamic in favour of new .dyn
  • Loading branch information
soywiz committed Feb 4, 2021
1 parent 3d90175 commit 54160f5
Show file tree
Hide file tree
Showing 34 changed files with 734 additions and 399 deletions.
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# sytleguide
kotlin.code.style=official

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

# version
group=com.soywiz.korlibs.korio
Expand All @@ -12,10 +12,10 @@ version=2.0.0-SNAPSHOT
coroutinesVersion=1.4.2

# korlibs
klockVersion=2.0.5
kdsVersion=2.0.5
kmemVersion=2.0.5
kryptoVersion=2.0.5
klockVersion=2.0.6
kdsVersion=2.0.6
kmemVersion=2.0.6
kryptoVersion=2.0.6

# bintray location
project.bintray.org=korlibs
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import com.soywiz.korio.android.androidContext
import com.soywiz.klock.*
import com.soywiz.korio.file.*
import com.soywiz.korio.internal.*
import com.soywiz.korio.lang.Closeable
import com.soywiz.korio.stream.*
import com.soywiz.korio.util.*
Expand Down Expand Up @@ -93,7 +94,7 @@ class AndroidResourcesVfs(var context: Context?) : Vfs() {
val temp = ByteArray(16 * 1024)
var available = (range.endExclusiveClamped - range.start)
while (available >= 0) {
val read = fs.read(temp, 0, Math.min(temp.size.toLong(), available).toInt())
val read = fs.read(temp, 0, min2(temp.size.toLong(), available).toInt())
if (read <= 0) break
out.write(temp, 0, read)
available -= read
Expand Down Expand Up @@ -181,8 +182,8 @@ private class LocalVfsJvm : LocalVfsV2() {
override suspend fun readRange(path: String, range: LongRange): ByteArray = executeIo {
RandomAccessFile(resolveFile(path), "r").use { raf ->
val fileLength = raf.length()
val start = kotlin.math.min(range.start, fileLength)
val end = kotlin.math.min(range.endInclusive, fileLength - 1) + 1
val start = min2(range.start, fileLength)
val end = min2(range.endInclusive, fileLength - 1) + 1
val totalRead = (end - start).toInt()
val out = ByteArray(totalRead)
raf.seek(start)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.soywiz.korio.async

import com.soywiz.kmem.*
import com.soywiz.korio.internal.*
import com.soywiz.korio.internal.min2
import com.soywiz.korio.stream.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
Expand Down Expand Up @@ -47,7 +49,7 @@ fun ReceiveChannel<ByteArray>.toAsyncInputStream(): AsyncInputStream {
currentPos = 0
}

val toRead = min(currentAvailable, len)
val toRead = min2(currentAvailable, len)
arraycopy(currentData, currentPos, buffer, offset, toRead)
currentPos += toRead
return toRead
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import com.soywiz.kmem.*
import com.soywiz.korio.compression.*
import com.soywiz.korio.compression.util.*
import com.soywiz.korio.experimental.*
import com.soywiz.korio.internal.*
import com.soywiz.korio.internal.min2
import com.soywiz.korio.stream.*
import kotlin.math.*

Expand All @@ -20,7 +22,7 @@ open class DeflatePortable(val windowBits: Int) : CompressionMethod {
) {
while (i.hasAvailable()) {
val available = i.getAvailable()
val chunkSize = min(available, 0xFFFFL).toInt()
val chunkSize = min2(available, 0xFFFFL).toInt()
o.write8(if (chunkSize >= available) 1 else 0)
o.write16LE(chunkSize)
o.write16LE(chunkSize.inv())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
package com.soywiz.korio.compression.lzma

import com.soywiz.korio.experimental.*
import com.soywiz.korio.internal.*
import com.soywiz.korio.internal.max2
import com.soywiz.korio.stream.*
import com.soywiz.korio.util.checksum.*
import kotlin.math.*
Expand Down Expand Up @@ -533,8 +535,8 @@ object SevenZip {
if (dictionarySize < 0) return false
if (m_DictionarySize != dictionarySize) {
m_DictionarySize = dictionarySize
m_DictionarySizeCheck = max(m_DictionarySize, 1)
m_OutWindow.create(max(m_DictionarySizeCheck, 1 shl 12))
m_DictionarySizeCheck = max2(m_DictionarySize, 1)
m_OutWindow.create(max2(m_DictionarySizeCheck, 1 shl 12))
}
return true
}
Expand Down Expand Up @@ -1414,7 +1416,7 @@ object SevenZip {
}

var numAvailableBytesFull = _matchFinder!!.getNumAvailableBytes() + 1
numAvailableBytesFull = min(kNumOpts - 1 - cur, numAvailableBytesFull)
numAvailableBytesFull = min2(kNumOpts - 1 - cur, numAvailableBytesFull)
numAvailableBytes = numAvailableBytesFull

if (numAvailableBytes < 2)
Expand All @@ -1423,7 +1425,7 @@ object SevenZip {
numAvailableBytes = _numFastBytes
if (!nextIsChar && matchByte != currentByte) {
// try Literal + rep0
val t = min(numAvailableBytesFull - 1, _numFastBytes)
val t = min2(numAvailableBytesFull - 1, _numFastBytes)
val lenTest2 = _matchFinder!!.getMatchLen(0, reps[0], t)
if (lenTest2 >= 2) {
val state2 = LzmaBase.stateUpdateChar(state)
Expand Down Expand Up @@ -1483,7 +1485,7 @@ object SevenZip {

// if (_maxMode)
if (lenTest < numAvailableBytesFull) {
val t = min(numAvailableBytesFull - 1 - lenTest, _numFastBytes)
val t = min2(numAvailableBytesFull - 1 - lenTest, _numFastBytes)
val lenTest2 = _matchFinder!!.getMatchLen(lenTest, reps[repIndex], t)
if (lenTest2 >= 2) {
var state2 =
Expand Down Expand Up @@ -1572,7 +1574,7 @@ object SevenZip {

if (lenTest == _matchDistances[offs]) {
if (lenTest < numAvailableBytesFull) {
val t = min(numAvailableBytesFull - 1 - lenTest, _numFastBytes)
val t = min2(numAvailableBytesFull - 1 - lenTest, _numFastBytes)
val lenTest2 = _matchFinder!!.getMatchLen(lenTest, curBack, t)
if (lenTest2 >= 2) {
var state2 =
Expand Down Expand Up @@ -2202,7 +2204,7 @@ object SevenZip {
_cyclicBufferPos - delta + _cyclicBufferSize) shl 1

val pby1 = _bufferOffset + curMatch
var len = min(len0, len1)
var len = min2(len0, len1)
if (_bufferBase!![pby1 + len] == _bufferBase!![cur + len]) {
while (++len != lenLimit)
if (_bufferBase!![pby1 + len] != _bufferBase!![cur + len])
Expand Down Expand Up @@ -2291,7 +2293,7 @@ object SevenZip {
_cyclicBufferPos - delta + _cyclicBufferSize) shl 1

val pby1 = _bufferOffset + curMatch
var len = min(len0, len1)
var len = min2(len0, len1)
if (_bufferBase!![pby1 + len] == _bufferBase!![cur + len]) {
while (++len != lenLimit)
if (_bufferBase!![pby1 + len] != _bufferBase!![cur + len])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.soywiz.korio.compression.util
import com.soywiz.kds.*
import com.soywiz.kmem.*
import com.soywiz.korio.experimental.*
import com.soywiz.korio.internal.*
import com.soywiz.korio.internal.min2
import com.soywiz.korio.lang.*
import com.soywiz.korio.stream.*
import kotlin.math.*
Expand Down Expand Up @@ -38,7 +40,7 @@ open class BitReader(val s: AsyncInputStreamWithLength) : AsyncInputStreamWithLe
private val tempBA = ByteArray(BIG_CHUNK_SIZE)
suspend fun prepareBytesUpTo(expectedBytes: Int): BitReader {
while (sbuffers.availableRead < expectedBytes) {
val read = s.read(tempBA, 0, min(tempBA.size, expectedBytes))
val read = s.read(tempBA, 0, min2(tempBA.size, expectedBytes))
if (read <= 0) break // No more data
sbuffers.write(tempBA, 0, read)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import com.soywiz.kmem.extract
import com.soywiz.kmem.toIntClamp
import com.soywiz.kmem.unsigned
import com.soywiz.korio.file.*
import com.soywiz.korio.internal.*
import com.soywiz.korio.internal.indexOf
import com.soywiz.korio.internal.max2
import com.soywiz.korio.stream.*
import com.soywiz.krypto.encoding.*
import kotlin.math.max
Expand Down Expand Up @@ -37,9 +39,9 @@ class ZipFile private constructor(
val fileLength = s.getLength()

for (chunkSize in listOf(0x16, 0x100, 0x1000, 0x10000)) {
val pos = max(0L, fileLength - chunkSize)
val pos = max2(0L, fileLength - chunkSize)
s.setPosition(pos)
val bytesLen = max(chunkSize, s.getAvailable().toIntClamp())
val bytesLen = max2(chunkSize, s.getAvailable().toIntClamp())
val ebytes = s.readBytesExact(bytesLen)
endBytes = ebytes
pk_endIndex = endBytes.indexOf(PK_END)
Expand Down
Loading

0 comments on commit 54160f5

Please sign in to comment.