commit 3efd91716902e7592304e78bd78ab95d961869ff Author: iwakeh iwakeh@torproject.org Date: Sat Feb 3 08:19:55 2018 +0000
Use 'putIfAbsent'. --- .../org/torproject/descriptor/log/WebServerAccessLogLine.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/src/main/java/org/torproject/descriptor/log/WebServerAccessLogLine.java b/src/main/java/org/torproject/descriptor/log/WebServerAccessLogLine.java index a4e3ce6..4884733 100644 --- a/src/main/java/org/torproject/descriptor/log/WebServerAccessLogLine.java +++ b/src/main/java/org/torproject/descriptor/log/WebServerAccessLogLine.java @@ -147,12 +147,8 @@ public class WebServerAccessLogLine {
private static <T> T fromMap(T val, Map<T, T> map) { synchronized (map) { - T reference = map.get(val); - if (null == reference) { - map.put(val, val); - reference = map.get(val); - } - return reference; + map.putIfAbsent(val, val); + return map.get(val); } }
tor-commits@lists.torproject.org