--- jsr166/src/jsr166e/extra/ReadMostlyVector.java 2011/12/04 01:25:16 1.14 +++ jsr166/src/jsr166e/extra/ReadMostlyVector.java 2011/12/31 05:50:22 1.18 @@ -648,16 +648,12 @@ public class ReadMostlyVector long seq = lock.awaitAvailability(); int n = count; Object[] items = array; - if (n > items.length) - continue; - boolean outOfBounds = (index < 0 || index >= n); @SuppressWarnings("unchecked") - E e = outOfBounds ? null : (E) items[index]; + E e = (index < items.length) ? (E) items[index] : null; if (lock.getSequence() == seq) { - if (outOfBounds) + if (index >= n) throw new ArrayIndexOutOfBoundsException(index); - else - return e; + return e; } } } @@ -667,28 +663,7 @@ public class ReadMostlyVector } public int indexOf(Object o) { - final SequenceLock lock = this.lock; - for (;;) { - long seq = lock.awaitAvailability(); - Object[] items = array; - int n = count; - if (n <= items.length) { - for (int i = 0; i < n; ++i) { - Object e = items[i]; - if (lock.getSequence() != seq) { - lock.lock(); - try { - return rawIndexOf(o, 0, count); - } finally { - lock.unlock(); - } - } - else if ((o == null) ? e == null : o.equals(e)) - return i; - } - return -1; - } - } + return indexOf(o, 0); } public boolean isEmpty() { @@ -954,7 +929,7 @@ public class ReadMostlyVector if (index < 0) ex = true; else - idx = rawIndexOf(o, 0, count); + idx = rawIndexOf(o, index, count); } finally { lock.unlock(); } @@ -1136,7 +1111,7 @@ public class ReadMostlyVector } } - static final class Itr implements ListIterator, Enumeration { + static final class Itr implements ListIterator, Enumeration { final ReadMostlyVector list; final SequenceLock lock; Object[] items;