Skip to content

Commit 68e1800

Browse files
authored
chore: Clean up find uses and refactor policy plugin loading (#20)
1 parent a330b16 commit 68e1800

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

core/src/commonMain/kotlin/com/deezer/caupain/internal/cache.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private class CachingCacheStorage(
7676
store[url] = delegate.findAll(url)
7777
}
7878
val data = store.getValue(url)
79-
return data.find {
79+
return data.firstOrNull {
8080
varyKeys.all { (key, value) -> it.varyKeys[key] == value } && varyKeys.size == it.varyKeys.size
8181
}
8282
}
@@ -115,7 +115,7 @@ private class FileCacheStorage(
115115

116116
override suspend fun find(url: Url, varyKeys: Map<String, String>): CachedResponseData? {
117117
val data = readCache(key(url))
118-
return data.find {
118+
return data.firstOrNull {
119119
varyKeys.all { (key, value) -> it.varyKeys[key] == value } && varyKeys.size == it.varyKeys.size
120120
}
121121
}

core/src/jvmMain/kotlin/com/deezer/caupain/model/ServiceLoaderPolicies.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ import java.util.ServiceLoader
3333
internal actual fun loadPolicies(paths: Iterable<Path>, logger: Logger): Iterable<Policy> {
3434
val childClassLoader = URLClassLoader(
3535
paths
36-
.asSequence()
37-
.map { it.toNioPath().toUri().toURL() }
38-
.toList()
36+
.mapTo(mutableListOf()) { it.toNioPath().toUri().toURL() }
3937
.toTypedArray(),
4038
Policy::class.java.classLoader
4139
)

0 commit comments

Comments
 (0)