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.18 by jsr166, Sat Dec 31 05:50:22 2011 UTC vs.
Revision 1.19 by jsr166, Sat Dec 31 06:21:46 2011 UTC

# Line 870 | Line 870 | public class ReadMostlyVector<E>
870          for (;;) {
871              long seq = lock.awaitAvailability();
872              Object[] items = array;
873            int len = items.length;
873              int n = count;
875            if (n > len)
876                continue;
877            boolean empty = (n == 0);
874              @SuppressWarnings("unchecked")
875 <            E e = empty ? null : (E) items[0];
875 >            E e = (items.length > 0) ? (E) items[0] : null;
876              if (lock.getSequence() == seq) {
877 <                if (empty)
877 >                if (n <= 0)
878                      throw new NoSuchElementException();
879 <                else
884 <                    return e;
879 >                return e;
880              }
881          }
882      }
# Line 892 | Line 887 | public class ReadMostlyVector<E>
887          for (;;) {
888              long seq = lock.awaitAvailability();
889              Object[] items = array;
895            int len = items.length;
890              int n = count;
897            if (n > len)
898                continue;
899            boolean empty = (n == 0);
891              @SuppressWarnings("unchecked")
892 <            E e = empty ? null : (E) items[n - 1];
892 >            E e = (n > 0 && items.length >= n) ? (E) items[n - 1] : null;
893              if (lock.getSequence() == seq) {
894 <                if (empty)
894 >                if (n <= 0)
895                      throw new NoSuchElementException();
896 <                else
906 <                    return e;
896 >                return e;
897              }
898          }
899      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines