Do not create an intermediate list

This commit is contained in:
Albert Vaca Cintora
2025-10-03 23:12:14 +02:00
parent f70a6de38f
commit f902ce7fda

View File

@@ -429,11 +429,15 @@ class Device : PacketReceiver {
Log.w("Device", "Ignoring packet with type ${np.type} because no plugin can handle it")
return
}
targetPlugins.mapNotNull { it to loadedPlugins[it] }.forEach { (pluginKey, plugin) ->
plugin.runCatching {
if (isPaired) onPacketReceived(np) else onUnpairedDevicePacketReceived(np)
targetPlugins.asSequence().mapNotNull { loadedPlugins[it] }.forEach { plugin ->
runCatching {
if (isPaired) {
plugin.onPacketReceived(np)
} else {
plugin.onUnpairedDevicePacketReceived(np)
}
}.onFailure { e ->
Log.e("Device", "Exception in ${pluginKey}'s onPacketReceived()", e)
Log.e("Device", "Exception in ${plugin.pluginKey}'s onPacketReceived()", e)
}
}
}