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

Comparing jsr166/src/main/java/util/concurrent/CopyOnWriteArrayList.java (file contents):
Revision 1.128 by jsr166, Sun Feb 22 05:08:16 2015 UTC vs.
Revision 1.129 by jsr166, Tue May 19 06:32:59 2015 UTC

# Line 25 | Line 25 | import java.util.Iterator;
25   import java.util.List;
26   import java.util.ListIterator;
27   import java.util.NoSuchElementException;
28 + import java.util.Objects;
29   import java.util.RandomAccess;
30   import java.util.Spliterator;
31   import java.util.Spliterators;
# Line 155 | Line 156 | public class CopyOnWriteArrayList<E>
156      }
157  
158      /**
158     * Tests for equality, coping with nulls.
159     */
160    private static boolean eq(Object o1, Object o2) {
161        return (o1 == null) ? o2 == null : o1.equals(o2);
162    }
163
164    /**
159       * static version of indexOf, to allow repeated calls without
160       * needing to re-acquire array each time.
161       * @param o element to search for
# Line 507 | Line 501 | public class CopyOnWriteArrayList<E>
501              if (snapshot != current) findIndex: {
502                  int prefix = Math.min(index, len);
503                  for (int i = 0; i < prefix; i++) {
504 <                    if (current[i] != snapshot[i] && eq(o, current[i])) {
504 >                    if (current[i] != snapshot[i]
505 >                        && Objects.equals(o, current[i])) {
506                          index = i;
507                          break findIndex;
508                      }
# Line 587 | Line 582 | public class CopyOnWriteArrayList<E>
582                  // Optimize for lost race to another addXXX operation
583                  int common = Math.min(snapshot.length, len);
584                  for (int i = 0; i < common; i++)
585 <                    if (current[i] != snapshot[i] && eq(e, current[i]))
585 >                    if (current[i] != snapshot[i]
586 >                        && Objects.equals(e, current[i]))
587                          return false;
588                  if (indexOf(e, current, common, len) >= 0)
589                          return false;
# Line 953 | Line 949 | public class CopyOnWriteArrayList<E>
949          List<?> list = (List<?>)o;
950          Iterator<?> it = list.iterator();
951          Object[] elements = getArray();
952 <        int len = elements.length;
953 <        for (int i = 0; i < len; ++i)
958 <            if (!it.hasNext() || !eq(elements[i], it.next()))
952 >        for (int i = 0, len = elements.length; i < len; i++)
953 >            if (!it.hasNext() || !Objects.equals(elements[i], it.next()))
954                  return false;
955          if (it.hasNext())
956              return false;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines