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 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?> { fun <U> associateWith(transform: (K, V) -> U?): Map<K, U?> {
val runner = CacheCollectors.BiAssociateWithCollector(size(), transform) val runner = CacheCollectors.BiAssociateWithCollector(size(), transform)
forEach(runner) forEach(runner)
return runner.results 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( fun joinToString(
separator: CharSequence = ", ", separator: CharSequence = ", ",
prefix: CharSequence = "", prefix: CharSequence = "",

View File

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

View File

@@ -78,7 +78,7 @@ class LargeSoftCache<K, V> : CacheOperations<K, V> {
key: K, key: K,
builder: (key: K) -> V, builder: (key: K) -> V,
): V { ): V {
val softRef = cache.get(key) val softRef = cache[key]
val value = softRef?.get() val value = softRef?.get()
return if (value != null) { 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 * Proactively cleans up the cache by removing entries whose weakly referenced
* objects have been garbage collected. While `get` handles cleanup on access, * objects have been garbage collected. While `get` handles cleanup on access,