You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2020/12/23 00:52:05 UTC

[GitHub] [zookeeper] lanicc commented on a change in pull request #1561: ZOOKEEPER-4032: Use `Map.computeIfAbsent` instead of `if Map.get is null then put value`

lanicc commented on a change in pull request #1561:
URL: https://github.com/apache/zookeeper/pull/1561#discussion_r547577251



##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/watch/WatchManager.java
##########
@@ -74,22 +74,10 @@ public synchronized boolean addWatch(String path, Watcher watcher, WatcherMode w
             return false;
         }
 
-        Set<Watcher> list = watchTable.get(path);
-        if (list == null) {
-            // don't waste memory if there are few watches on a node
-            // rehash when the 4th entry is added, doubling size thereafter
-            // seems like a good compromise
-            list = new HashSet<>(4);
-            watchTable.put(path, list);

Review comment:
       Maybe It's not necessary




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org