Skip to content

Commit

Permalink
Don't use buildMap
Browse files Browse the repository at this point in the history
  • Loading branch information
BoD committed Apr 4, 2024
1 parent 26762c7 commit de77e99
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1384,18 +1384,18 @@ internal class LocalCache<K : Any, V : Any>(builder: CacheBuilder<K, V>) {
if (count.value == 0) return emptyMap()
reentrantLock.lock()
return try {
buildMap {
val table = table.value
for (i in 0 until table.size) {
var e = table[i]
while (e != null) {
if (e.valueReference!!.isActive) {
put(e.key, e.valueReference!!.get()!!)
}
e = e.next
val activeMap = mutableMapOf<K, V>()
val table = table.value
for (i in 0 until table.size) {
var e = table[i]
while (e != null) {
if (e.valueReference?.isActive == true) {
activeMap[e.key] = e.valueReference?.get()!!
}
e = e.next
}
}
activeMap.ifEmpty { emptyMap() }
} finally {
reentrantLock.unlock()
}
Expand Down

0 comments on commit de77e99

Please sign in to comment.