ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/ConcurrentHashMap.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/ConcurrentHashMap.java (file contents):
Revision 1.295 by jsr166, Sun Jul 17 04:23:31 2016 UTC vs.
Revision 1.296 by dl, Sun Jul 17 12:09:12 2016 UTC

# Line 994 | Line 994 | public class ConcurrentHashMap<K,V> exte
994          int hash = spread(key.hashCode());
995          int binCount = 0;
996          for (Node<K,V>[] tab = table;;) {
997 <            Node<K,V> f; int n, i, fh;
997 >            Node<K,V> f; int n, i, fh; K fk; V fv;
998              if (tab == null || (n = tab.length) == 0)
999                  tab = initTable();
1000              else if ((f = tabAt(tab, i = (n - 1) & hash)) == null) {
# Line 1003 | Line 1003 | public class ConcurrentHashMap<K,V> exte
1003              }
1004              else if ((fh = f.hash) == MOVED)
1005                  tab = helpTransfer(tab, f);
1006 +            else if (onlyIfAbsent && fh == hash &&  // check first node
1007 +                     ((fk = f.key) == key || fk != null && key.equals(fk)) &&
1008 +                     (fv = f.val) != null)
1009 +                return fv;
1010              else {
1011                  V oldVal = null;
1012                  synchronized (f) {
# Line 1673 | Line 1677 | public class ConcurrentHashMap<K,V> exte
1677          V val = null;
1678          int binCount = 0;
1679          for (Node<K,V>[] tab = table;;) {
1680 <            Node<K,V> f; int n, i, fh;
1680 >            Node<K,V> f; int n, i, fh; K fk; V fv;
1681              if (tab == null || (n = tab.length) == 0)
1682                  tab = initTable();
1683              else if ((f = tabAt(tab, i = (n - 1) & h)) == null) {
# Line 1695 | Line 1699 | public class ConcurrentHashMap<K,V> exte
1699              }
1700              else if ((fh = f.hash) == MOVED)
1701                  tab = helpTransfer(tab, f);
1702 +            else if (fh == h &&                  // check first node
1703 +                     ((fk = f.key) == key || fk != null && key.equals(fk)) &&
1704 +                     (fv = f.val) != null)
1705 +                return fv;
1706              else {
1707                  boolean added = false;
1708                  synchronized (f) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines