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

Comparing jsr166/src/main/java/util/ArrayDeque.java (file contents):
Revision 1.124 by jsr166, Mon Nov 28 02:52:36 2016 UTC vs.
Revision 1.125 by jsr166, Sun Dec 4 23:42:56 2016 UTC

# Line 117 | Line 117 | public class ArrayDeque<E> extends Abstr
117          if (jump < needed
118              || (newCapacity = (oldCapacity + jump)) - MAX_ARRAY_SIZE > 0)
119              newCapacity = newCapacity(needed, jump);
120 <        elements = Arrays.copyOf(elements, newCapacity);
120 >        final Object[] es = elements = Arrays.copyOf(elements, newCapacity);
121          // Exceptionally, here tail == head needs to be disambiguated
122 <        if (tail < head || (tail == head && elements[head] != null)) {
122 >        if (tail < head || (tail == head && es[head] != null)) {
123              // wrap around; slide first leg forward to end of array
124              int newSpace = newCapacity - oldCapacity;
125 <            System.arraycopy(elements, head,
126 <                             elements, head + newSpace,
125 >            System.arraycopy(es, head,
126 >                             es, head + newSpace,
127                               oldCapacity - head);
128 <            Arrays.fill(elements, head, head + newSpace, null);
129 <            head += newSpace;
128 >            for (int i = head, to = (head += newSpace); i < to; i++)
129 >                es[i] = null;
130          }
131          // checkInvariants();
132      }
# Line 1076 | Line 1076 | public class ArrayDeque<E> extends Abstr
1076  
1077      /**
1078       * Nulls out slots starting at array index i, upto index end.
1079 +     * Condition i == end means "empty" - nothing to do.
1080       */
1081      private static void circularClear(Object[] es, int i, int end) {
1082 +        // assert 0 <= i && i < es.length;
1083 +        // assert 0 <= end && end < es.length;
1084          for (int to = (i <= end) ? end : es.length;
1085               ; i = 0, to = end) {
1086 <            Arrays.fill(es, i, to, null);
1086 >            for (; i < to; i++) es[i] = null;
1087              if (to == end) break;
1088          }
1089      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines