Fix issues needing a fix caught by review.

This commit is contained in:
KotlinGeekDev
2026-03-04 13:51:46 +01:00
parent 7b6db9404c
commit 4cea4e4f5d
5 changed files with 18 additions and 16 deletions
+1 -2
View File
@@ -3,7 +3,6 @@
import com.vanniktech.maven.publish.KotlinMultiplatform import com.vanniktech.maven.publish.KotlinMultiplatform
import io.github.frankois944.spmForKmp.swiftPackageConfig import io.github.frankois944.spmForKmp.swiftPackageConfig
import io.github.frankois944.spmForKmp.utils.ExperimentalSpmForKmpFeature import io.github.frankois944.spmForKmp.utils.ExperimentalSpmForKmpFeature
import org.gradle.kotlin.dsl.androidLibrary
import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest
@@ -25,7 +24,7 @@ kotlin {
} }
} }
androidLibrary { android {
namespace = "com.vitorpamplona.quartz" namespace = "com.vitorpamplona.quartz"
compileSdk = compileSdk =
libs.versions.android.compileSdk libs.versions.android.compileSdk
@@ -31,7 +31,7 @@ actual object Rfc3986 {
actual fun normalize(uri: String): String = actual fun normalize(uri: String): String =
rfc3986UriBridge rfc3986UriBridge
.normalizeUrlWithUrl(uri, null) .normalizeUrlWithUrl(uri, null)
.let { if (it?.last() == '/') it else "$it/" } ?.let { if (it.last() == '/') it else "$it/" } ?: throw Exception("Could not normalize URI: $uri")
actual fun isValidUrl(url: String): Boolean = rfc3986UriBridge.isUrlValidWithUrl(url) actual fun isValidUrl(url: String): Boolean = rfc3986UriBridge.isUrlValidWithUrl(url)
@@ -80,7 +80,7 @@ actual class LargeCache<K, V> : ICacheOperations<K, V> {
} else { } else {
val newObject = builder(key) val newObject = builder(key)
concurrentMap.put(key, newObject) concurrentMap.put(key, newObject)
concurrentMap[key] == null concurrentMap[key] != null
} }
} }
@@ -108,7 +108,7 @@ actual class LargeCache<K, V> : ICacheOperations<K, V> {
actual override fun <R> mapNotNullIntoSet(consumer: CacheCollectors.BiMapper<K, V, R?>): Set<R> = mapNotNull(consumer).toSet() actual override fun <R> mapNotNullIntoSet(consumer: CacheCollectors.BiMapper<K, V, R?>): Set<R> = mapNotNull(consumer).toSet()
actual override fun <R> mapFlatten(consumer: CacheCollectors.BiMapper<K, V, Collection<R>?>): List<R> = concurrentMap.flatMap { consumer.map(it.key, it.value) as Iterable<R> } actual override fun <R> mapFlatten(consumer: CacheCollectors.BiMapper<K, V, Collection<R>?>): List<R> = concurrentMap.flatMap { entry -> consumer.map(entry.key, entry.value) ?: emptyList() }
actual override fun <R> mapFlattenIntoSet(consumer: CacheCollectors.BiMapper<K, V, Collection<R>?>): Set<R> = mapFlatten(consumer).toSet() actual override fun <R> mapFlattenIntoSet(consumer: CacheCollectors.BiMapper<K, V, Collection<R>?>): Set<R> = mapFlatten(consumer).toSet()
@@ -312,10 +312,14 @@ fun <K, V> CacheMap<K, V>.subMapAlt(
val keySet = keys val keySet = keys
val fromIndex = keySet.indexOf(from) val fromIndex = keySet.indexOf(from)
val toIndex = keySet.indexOf(to) val toIndex = keySet.indexOf(to)
for (index in fromIndex..toIndex) { for (index in fromIndex until toIndex) {
val correspondingEntry = entries.elementAt(index) val correspondingEntry = entries.elementAt(index)
resultMap[correspondingEntry.key] = correspondingEntry.value resultMap[correspondingEntry.key] = correspondingEntry.value
} }
if (toInclusive) {
val correspondingToEntry = entries.elementAt(toIndex)
resultMap[correspondingToEntry.key] = correspondingToEntry.value
}
return resultMap return resultMap
} }
@@ -332,10 +336,6 @@ fun <K, V> Map<K, V>.maxOrNullOf(
): V? { ): V? {
var maxK: K? = null var maxK: K? = null
var maxV: V? = null var maxV: V? = null
val finalMaxK: K? = maxK
val finalMaxV: V? = maxV
forEach { forEach {
if (filter.filter(it.key, it.value)) { if (filter.filter(it.key, it.value)) {
if (maxK == null || (maxV != null && comparator.compare(it.value, maxV) > 0)) { if (maxK == null || (maxV != null && comparator.compare(it.value, maxV) > 0)) {
@@ -345,21 +345,22 @@ fun <K, V> Map<K, V>.maxOrNullOf(
} }
} }
val finalMaxK: K? = maxK
val finalMaxV: V? = maxV
return finalMaxV return finalMaxV
} }
fun <K, V> Map<K, V>.sumOf(consumer: CacheCollectors.BiSumOf<K, V>): Int { fun <K, V> Map<K, V>.sumOf(consumer: CacheCollectors.BiSumOf<K, V>): Int {
var sum = 0 var sum = 0
val totalSum = sum
forEach { sum += consumer.map(it.key, it.value) } forEach { sum += consumer.map(it.key, it.value) }
return totalSum return sum
} }
fun <K, V> Map<K, V>.sumOfLong(consumer: CacheCollectors.BiSumOfLong<K, V>): Long { fun <K, V> Map<K, V>.sumOfLong(consumer: CacheCollectors.BiSumOfLong<K, V>): Long {
var sum = 0L var sum = 0L
val totalSum = sum
forEach { sum += consumer.map(it.key, it.value) } forEach { sum += consumer.map(it.key, it.value) }
return totalSum return sum
} }
fun <K, V, R> Map<K, V>.groupBy(consumer: CacheCollectors.BiNotNullMapper<K, V, R>): Map<R, List<V>> { fun <K, V, R> Map<K, V>.groupBy(consumer: CacheCollectors.BiNotNullMapper<K, V, R>): Map<R, List<V>> {
@@ -227,7 +227,7 @@ class CustomBitSet(
} }
fun clear() { fun clear() {
for (i in 0..words.size) words[i] = 0 for (i in words.indices) words[i] = 0
} }
private constructor(longArray: LongArray) : this(0) { private constructor(longArray: LongArray) : this(0) {
@@ -38,7 +38,7 @@ actual class MacInstance actual constructor(
.keyDecoder(digestForAlgorithm(algorithm)) .keyDecoder(digestForAlgorithm(algorithm))
.decodeFromByteArrayBlocking(HMAC.Key.Format.RAW, key) .decodeFromByteArrayBlocking(HMAC.Key.Format.RAW, key)
private val hmacSignFunction = internalMacInstance.signatureGenerator().createSignFunction() private var hmacSignFunction = internalMacInstance.signatureGenerator().createSignFunction()
actual fun init( actual fun init(
key: ByteArray, key: ByteArray,
@@ -49,6 +49,8 @@ actual class MacInstance actual constructor(
.get(HMAC) .get(HMAC)
.keyDecoder(digestForAlgorithm(algorithm)) .keyDecoder(digestForAlgorithm(algorithm))
.decodeFromByteArrayBlocking(HMAC.Key.Format.RAW, key) .decodeFromByteArrayBlocking(HMAC.Key.Format.RAW, key)
hmacSignFunction = internalMacInstance.signatureGenerator().createSignFunction()
} }
actual fun getMacLength(): Int = hmacSignFunction.signIntoByteArray(internalMacInstance.encodeToByteArrayBlocking(HMAC.Key.Format.RAW)) actual fun getMacLength(): Int = hmacSignFunction.signIntoByteArray(internalMacInstance.encodeToByteArrayBlocking(HMAC.Key.Format.RAW))