summaryrefslogtreecommitdiffhomepage
path: root/tunnel/src/main/java/com/wireguard
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-09-21 11:16:33 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2020-09-21 11:16:33 +0200
commitd738161a2ebd6d6494ea5357026fa33884633ae4 (patch)
treeae48da51a2ceb30898260081bac83d11f55c91a5 /tunnel/src/main/java/com/wireguard
parent52c2e9cd24c263ea0cdfeaf4c866aa523b43c48b (diff)
Statistics: only do one hash lookup
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'tunnel/src/main/java/com/wireguard')
-rw-r--r--tunnel/src/main/java/com/wireguard/android/backend/Statistics.java10
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;
}
/**