mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 16:46:44 +01:00
Lint issues: remove unused methods, use indexing operator instead of .get()
This commit is contained in:
@@ -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 = "",
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user