Lint issues: remove unused methods, use indexing operator instead of .get()

This commit is contained in:
David Kaspar
2025-08-16 11:20:37 +01:00
parent 533d8b18f0
commit f21c7bd258
3 changed files with 2 additions and 28 deletions

View File

@@ -123,24 +123,12 @@ interface CacheOperations<K, V> {
return runner.results
}
fun <T, U> associateNotNull(transform: (K, V) -> Pair<T, U>?): Map<T, U> {
val runner = CacheCollectors.BiAssociateNotNullCollector(size(), transform)
forEach(runner)
return runner.results
}
fun <U> associateWith(transform: (K, V) -> U?): Map<K, U?> {
val runner = CacheCollectors.BiAssociateWithCollector(size(), transform)
forEach(runner)
return runner.results
}
fun <U> associateNotNullWith(transform: (K, V) -> U): Map<K, U> {
val runner = CacheCollectors.BiAssociateNotNullWithCollector(size(), transform)
forEach(runner)
return runner.results
}
fun joinToString(
separator: CharSequence = ", ",
prefix: CharSequence = "",

View File

@@ -67,7 +67,7 @@ class LargeCache<K, V> : CacheOperations<K, V> {
key: K,
builder: (key: K) -> V,
): Boolean {
val value = cache.get(key)
val value = cache[key]
return if (value != null) {
false
} else {

View File

@@ -78,7 +78,7 @@ class LargeSoftCache<K, V> : CacheOperations<K, V> {
key: K,
builder: (key: K) -> V,
): V {
val softRef = cache.get(key)
val softRef = cache[key]
val value = softRef?.get()
return if (value != null) {
@@ -89,20 +89,6 @@ class LargeSoftCache<K, V> : CacheOperations<K, V> {
}
}
fun createIfAbsent(
key: K,
builder: (key: K) -> V,
): Boolean {
val softRef = cache.get(key)
val value = softRef?.get()
return if (value != null) {
false
} else {
val newObject = builder(key)
cache.putIfAbsent(key, WeakReference(newObject)) == null
}
}
/**
* Proactively cleans up the cache by removing entries whose weakly referenced
* objects have been garbage collected. While `get` handles cleanup on access,