Repository: groovy
Updated Branches:
  refs/heads/master 6617e30e9 -> afac5ed6d


Avoid computing if entry is present


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/afac5ed6
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/afac5ed6
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/afac5ed6

Branch: refs/heads/master
Commit: afac5ed6dcfe747fbad5263772263ad4e037cbd3
Parents: 6617e30
Author: sunlan <[email protected]>
Authored: Mon Jan 8 16:57:46 2018 +0800
Committer: sunlan <[email protected]>
Committed: Mon Jan 8 16:57:46 2018 +0800

----------------------------------------------------------------------
 .../util/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java  | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/afac5ed6/src/main/java/org/apache/groovy/util/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/groovy/util/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java
 
b/src/main/java/org/apache/groovy/util/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java
index 5275b27..f368bd8 100644
--- 
a/src/main/java/org/apache/groovy/util/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java
+++ 
b/src/main/java/org/apache/groovy/util/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java
@@ -779,8 +779,10 @@ public final class ConcurrentLinkedHashMap<K, V> extends 
AbstractMap<K, V>
 
       Node<K, V> node = objectHolder.getObject();
       if (null == node) {
-        f.apply(key);
-        node = objectHolder.getObject();
+        V value = null;
+        final int weight = 1; // weigher.weightOf(key, value);
+        final WeightedValue<V> weightedValue = new WeightedValue<V>(value, 
weight);
+        node = new Node<K, V>(key, weightedValue);
       } else {
         // the return value of `computeIfAbsent` is different from the one of 
`putIfAbsent`.
         // if the key is absent in map, the return value of `computeIfAbsent` 
is the newly computed value, but `putIfAbsent` return null.

Reply via email to