diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-21 11:16:33 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-21 11:16:33 +0200 |
commit | d738161a2ebd6d6494ea5357026fa33884633ae4 (patch) | |
tree | ae48da51a2ceb30898260081bac83d11f55c91a5 /tunnel/src/main/java | |
parent | 52c2e9cd24c263ea0cdfeaf4c866aa523b43c48b (diff) |
Statistics: only do one hash lookup
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'tunnel/src/main/java')
-rw-r--r-- | tunnel/src/main/java/com/wireguard/android/backend/Statistics.java | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/tunnel/src/main/java/com/wireguard/android/backend/Statistics.java b/tunnel/src/main/java/com/wireguard/android/backend/Statistics.java index 60f78833..c9d51959 100644 --- a/tunnel/src/main/java/com/wireguard/android/backend/Statistics.java +++ b/tunnel/src/main/java/com/wireguard/android/backend/Statistics.java @@ -56,9 +56,10 @@ public class Statistics { * @return a long representing the number of bytes received by this peer. */ public long peerRx(final Key peer) { - if (!peerBytes.containsKey(peer)) + final Pair<Long, Long> rxTx = peerBytes.get(peer); + if (rxTx == null) return 0; - return peerBytes.get(peer).first; + return rxTx.first; } /** @@ -69,9 +70,10 @@ public class Statistics { * @return a long representing the number of bytes transmitted by this peer. */ public long peerTx(final Key peer) { - if (!peerBytes.containsKey(peer)) + final Pair<Long, Long> rxTx = peerBytes.get(peer); + if (rxTx == null) return 0; - return peerBytes.get(peer).second; + return rxTx.second; } /** |