mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-06-29 07:55:37 -04:00
chore: migrate kotlinx-collections-immutable to participial method names (#5991)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -71,19 +71,19 @@ class NodeManagerImpl(
|
||||
var nextById = byId
|
||||
// If the user.id changed (e.g. firmware reassigned the hex id) drop the stale id entry.
|
||||
if (previous != null && previous.user.id.isNotEmpty() && previous.user.id != node.user.id) {
|
||||
nextById = nextById.remove(previous.user.id)
|
||||
nextById = nextById.removing(previous.user.id)
|
||||
}
|
||||
if (node.user.id.isNotEmpty()) {
|
||||
nextById = nextById.put(node.user.id, node)
|
||||
nextById = nextById.putting(node.user.id, node)
|
||||
}
|
||||
return NodeIndex(byNum = byNum.put(num, node), byId = nextById)
|
||||
return NodeIndex(byNum = byNum.putting(num, node), byId = nextById)
|
||||
}
|
||||
|
||||
fun remove(num: Int): NodeIndex {
|
||||
val previous = byNum[num] ?: return this
|
||||
return NodeIndex(
|
||||
byNum = byNum.remove(num),
|
||||
byId = if (previous.user.id.isNotEmpty()) byId.remove(previous.user.id) else byId,
|
||||
byNum = byNum.removing(num),
|
||||
byId = if (previous.user.id.isNotEmpty()) byId.removing(previous.user.id) else byId,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -92,8 +92,8 @@ class NodeManagerImpl(
|
||||
var byNum = persistentMapOf<Int, Node>()
|
||||
var byId = persistentMapOf<String, Node>()
|
||||
for ((num, node) in nodes) {
|
||||
byNum = byNum.put(num, node)
|
||||
if (node.user.id.isNotEmpty()) byId = byId.put(node.user.id, node)
|
||||
byNum = byNum.putting(num, node)
|
||||
if (node.user.id.isNotEmpty()) byId = byId.putting(node.user.id, node)
|
||||
}
|
||||
return NodeIndex(byNum, byId)
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ internal class RequestTimer {
|
||||
|
||||
/** Records the start time for [requestId]. */
|
||||
fun start(requestId: Int) {
|
||||
startTimes.update { it.put(requestId, nowMillis) }
|
||||
startTimes.update { it.putting(requestId, nowMillis) }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,7 +46,7 @@ internal class RequestTimer {
|
||||
*/
|
||||
fun appendDuration(requestId: Int, text: String, logLabel: String): String {
|
||||
val start = startTimes.value[requestId]
|
||||
startTimes.update { it.remove(requestId) }
|
||||
startTimes.update { it.removing(requestId) }
|
||||
if (start == null) return text
|
||||
val seconds = (nowMillis - start) / MILLIS_PER_SECOND
|
||||
Logger.i { "$logLabel $requestId complete in $seconds s" }
|
||||
|
||||
@@ -63,7 +63,7 @@ class SessionManagerImpl(private val clock: Clock) : SessionManager {
|
||||
override fun recordSession(srcNodeNum: Int, passkey: ByteString) {
|
||||
if (passkey.size == 0) return
|
||||
val now = clock.now()
|
||||
entries.update { it.put(srcNodeNum, SessionEntry(passkey, now)) }
|
||||
entries.update { it.putting(srcNodeNum, SessionEntry(passkey, now)) }
|
||||
Logger.d { "Recorded session refresh from $srcNodeNum (${passkey.size} bytes)" }
|
||||
refreshFlow.tryEmit(srcNodeNum)
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ internal inline fun <K, V> cachedFlow(
|
||||
current[key]?.let {
|
||||
return it.value
|
||||
}
|
||||
if (cache.compareAndSet(current, current.put(key, newLazy))) {
|
||||
if (cache.compareAndSet(current, current.putting(key, newLazy))) {
|
||||
return newLazy.value
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user