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.100 by dl, Wed Apr 13 13:23:56 2011 UTC vs.
Revision 1.101 by jsr166, Thu Apr 14 01:17:58 2011 UTC

# Line 214 | Line 214 | public class ConcurrentHashMap<K, V> ext
214       */
215      @SuppressWarnings("unchecked")
216      static final <K,V> HashEntry<K,V> entryAt(HashEntry<K,V>[] tab, int i) {
217 <        return tab == null? null :
217 >        return (tab == null) ? null :
218              (HashEntry<K,V>) UNSAFE.getObjectVolatile
219              (tab, ((long)i << TSHIFT) + TBASE);
220      }
# Line 669 | Line 669 | public class ConcurrentHashMap<K, V> ext
669      @SuppressWarnings("unchecked")
670      static final <K,V> HashEntry<K,V> entryForHash(Segment<K,V> seg, int h) {
671          HashEntry<K,V>[] tab;
672 <        return seg == null || (tab = seg.table) == null? null :
672 >        return (seg == null || (tab = seg.table) == null) ? null :
673              (HashEntry<K,V>) UNSAFE.getObjectVolatile
674              (tab, ((long)(((tab.length - 1) & h)) << TSHIFT) + TBASE);
675      }
# Line 997 | Line 997 | public class ConcurrentHashMap<K, V> ext
997       * @throws NullPointerException if the specified key or value is null
998       */
999      public V put(K key, V value) {
1000        Segment<K,V> s;
1000          if (value == null)
1001              throw new NullPointerException();
1002          int hash = hash(key.hashCode());
1003          int j = (hash >>> segmentShift) & segmentMask;
1004 <        return ((s = segmentAt(segments, j)) == null? ensureSegment(j) : s).
1005 <            put(key, hash, value, false);
1004 >        Segment<K,V> s = segmentAt(segments, j);
1005 >        if (s == null)
1006 >            s = ensureSegment(j);
1007 >        return s.put(key, hash, value, false);
1008      }
1009  
1010      /**
# Line 1014 | Line 1015 | public class ConcurrentHashMap<K, V> ext
1015       * @throws NullPointerException if the specified key or value is null
1016       */
1017      public V putIfAbsent(K key, V value) {
1017        Segment<K,V> s;
1018          if (value == null)
1019              throw new NullPointerException();
1020          int hash = hash(key.hashCode());
1021          int j = (hash >>> segmentShift) & segmentMask;
1022 <        return ((s = segmentAt(segments, j)) == null? ensureSegment(j) : s).
1023 <            put(key, hash, value, true);
1022 >        Segment<K,V> s = segmentAt(segments, j);
1023 >        if (s == null)
1024 >            s = ensureSegment(j);
1025 >        return s.put(key, hash, value, true);
1026      }
1027  
1028      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines