From 2773c17327b79911dc17074d05da8a8360714f9f Mon Sep 17 00:00:00 2001 From: Mygod Date: Sun, 3 Feb 2019 13:47:22 +0800 Subject: [PATCH] Use MutableEntry correctly --- .../main/java/be/mygod/vpnhotspot/TetheringService.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt index 1b26c4c3..3d31f88e 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt @@ -64,10 +64,9 @@ class TetheringService : IpNeighbourMonitoringService() { val disableIpv6 = app.pref.getBoolean("service.disableIpv6", true) val iterator = routings.iterator() while (iterator.hasNext()) { - val (downstream, value) = iterator.next() - if (value != null) continue - try { - routings[downstream] = Routing(this, downstream).apply { + val entry = iterator.next() + if (entry.value == null) try { + entry.setValue(Routing(this, entry.key).apply { try { forward() masquerade(Routing.masquerade) @@ -77,7 +76,7 @@ class TetheringService : IpNeighbourMonitoringService() { revert() throw e } - } + }) } catch (e: Exception) { Timber.w(e) SmartSnackbar.make(e).show()