diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/IpNeighbourMonitor.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/IpNeighbourMonitor.kt index b0e07773..2b55761b 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/IpNeighbourMonitor.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/IpNeighbourMonitor.kt @@ -4,6 +4,7 @@ import be.mygod.vpnhotspot.net.IpDev import be.mygod.vpnhotspot.net.IpNeighbour import kotlinx.collections.immutable.PersistentMap import kotlinx.collections.immutable.persistentMapOf +import kotlinx.collections.immutable.toPersistentMap import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.channels.* @@ -71,11 +72,11 @@ class IpNeighbourMonitor private constructor() : IpMonitor() { } override suspend fun processLines(lines: Sequence) { - neighbours = lines - .flatMap { IpNeighbour.parse(it, fullMode).asSequence() } - .filter { it.state != IpNeighbour.State.DELETING } // skip entries without lladdr - .associateByTo(persistentMapOf().builder()) { IpDev(it) } - .build() + neighbours = mutableMapOf().apply { + for (line in lines) for (neigh in IpNeighbour.parse(line, fullMode)) { + if (neigh.state != IpNeighbour.State.DELETING) this[IpDev(neigh)] = neigh + } + }.toPersistentMap() aggregator.trySendBlocking(neighbours).onFailure { throw it!! } } }