ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/jsr166e/extra/ReadMostlyVector.java
(Generate patch)

Comparing jsr166/src/jsr166e/extra/ReadMostlyVector.java (file contents):
Revision 1.15 by jsr166, Mon Dec 19 19:18:35 2011 UTC vs.
Revision 1.18 by jsr166, Sat Dec 31 05:50:22 2011 UTC

# Line 648 | Line 648 | public class ReadMostlyVector<E>
648              long seq = lock.awaitAvailability();
649              int n = count;
650              Object[] items = array;
651            if (n > items.length)
652                continue;
653            boolean outOfBounds = (index < 0 || index >= n);
651              @SuppressWarnings("unchecked")
652 <            E e = outOfBounds ? null : (E) items[index];
652 >            E e = (index < items.length) ? (E) items[index] : null;
653              if (lock.getSequence() == seq) {
654 <                if (outOfBounds)
654 >                if (index >= n)
655                      throw new ArrayIndexOutOfBoundsException(index);
656 <                else
660 <                    return e;
656 >                return e;
657              }
658          }
659      }
# Line 667 | Line 663 | public class ReadMostlyVector<E>
663      }
664  
665      public int indexOf(Object o) {
666 <        final SequenceLock lock = this.lock;
671 <        for (;;) {
672 <            long seq = lock.awaitAvailability();
673 <            Object[] items = array;
674 <            int n = count;
675 <            if (n <= items.length) {
676 <                for (int i = 0; i < n; ++i) {
677 <                    Object e = items[i];
678 <                    if (lock.getSequence() != seq) {
679 <                        lock.lock();
680 <                        try {
681 <                            return rawIndexOf(o, 0, count);
682 <                        } finally {
683 <                            lock.unlock();
684 <                        }
685 <                    }
686 <                    else if ((o == null) ? e == null : o.equals(e))
687 <                        return i;
688 <                }
689 <                return -1;
690 <            }
691 <        }
666 >        return indexOf(o, 0);
667      }
668  
669      public boolean isEmpty() {
# Line 954 | Line 929 | public class ReadMostlyVector<E>
929                  if (index < 0)
930                      ex = true;
931                  else
932 <                    idx = rawIndexOf(o, 0, count);
932 >                    idx = rawIndexOf(o, index, count);
933              } finally {
934                  lock.unlock();
935              }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines