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

Commit

Permalink
Sync from next
Browse files Browse the repository at this point in the history
  • Loading branch information
soywiz committed Jun 26, 2021
1 parent 841cc6a commit 3bb4f3e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# sytleguide
kotlin.code.style=official

# Kotlin 1.5.0: https://github.com/korlibs/easy-kotlin-mpp-gradle-plugin
easyPluginVersion=0.15.2
# Kotlin 1.5.20: https://github.com/korlibs/easy-kotlin-mpp-gradle-plugin
easyPluginVersion=0.16.0

# version
group=com.soywiz.korlibs.krypto
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions krypto/src/commonMain/kotlin/com/soywiz/krypto/Hasher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.soywiz.krypto.encoding.Base64
import com.soywiz.krypto.encoding.Hex
import com.soywiz.krypto.internal.*
import com.soywiz.krypto.internal.arraycopy
import com.soywiz.krypto.internal.min2

import kotlin.math.min

open class HasherFactory(val create: () -> Hasher) {
Expand Down Expand Up @@ -37,7 +37,7 @@ abstract class Hasher(val chunkSize: Int, val digestSize: Int) {
var left = count
while (left > 0) {
val remainingInChunk = chunkSize - writtenInChunk
val toRead = min2(remainingInChunk, left)
val toRead = min(remainingInChunk, left)
arraycopy(data, curr, chunk, writtenInChunk, toRead)
left -= toRead
curr += toRead
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ internal fun ByteArray.readU8(o: Int): Int = this[o].toInt() and 0xFF
internal fun ByteArray.readS32_be(o: Int): Int =
(readU8(o + 3) shl 0) or (readU8(o + 2) shl 8) or (readU8(o + 1) shl 16) or (readU8(o + 0) shl 24)

@PublishedApi internal fun min2(a: Int, b: Int) = if (a < b) a else b
@PublishedApi internal fun max2(a: Int, b: Int) = if (a > b) a else b

@PublishedApi internal fun min2(a: Float, b: Float) = if (a < b) a else b
@PublishedApi internal fun max2(a: Float, b: Float) = if (a > b) a else b

@PublishedApi internal fun min2(a: Double, b: Double) = if (a < b) a else b
@PublishedApi internal fun max2(a: Double, b: Double) = if (a > b) a else b






0 comments on commit 3bb4f3e

Please sign in to comment.