| Index: third_party/protobuf/java/core/src/main/java/com/google/protobuf/BooleanArrayList.java
|
| diff --git a/third_party/protobuf/java/core/src/main/java/com/google/protobuf/BooleanArrayList.java b/third_party/protobuf/java/core/src/main/java/com/google/protobuf/BooleanArrayList.java
|
| index 8b2820b6e70fde1e24276211127e0e191bb66049..0d9f87ba01f401c9c543f5000c1842af789e9c38 100644
|
| --- a/third_party/protobuf/java/core/src/main/java/com/google/protobuf/BooleanArrayList.java
|
| +++ b/third_party/protobuf/java/core/src/main/java/com/google/protobuf/BooleanArrayList.java
|
| @@ -38,21 +38,22 @@ import java.util.RandomAccess;
|
|
|
| /**
|
| * An implementation of {@link BooleanList} on top of a primitive array.
|
| - *
|
| + *
|
| * @author dweis@google.com (Daniel Weis)
|
| */
|
| final class BooleanArrayList
|
| - extends AbstractProtobufList<Boolean> implements BooleanList, RandomAccess {
|
| -
|
| + extends AbstractProtobufList<Boolean>
|
| + implements BooleanList, RandomAccess {
|
| +
|
| private static final BooleanArrayList EMPTY_LIST = new BooleanArrayList();
|
| static {
|
| EMPTY_LIST.makeImmutable();
|
| }
|
| -
|
| +
|
| public static BooleanArrayList emptyList() {
|
| return EMPTY_LIST;
|
| }
|
| -
|
| +
|
| /**
|
| * The backing store for the list.
|
| */
|
| @@ -72,13 +73,14 @@ final class BooleanArrayList
|
| }
|
|
|
| /**
|
| - * Constructs a new mutable {@code BooleanArrayList}.
|
| + * Constructs a new mutable {@code BooleanArrayList}
|
| + * containing the same elements as {@code other}.
|
| */
|
| - private BooleanArrayList(boolean[] array, int size) {
|
| - this.array = array;
|
| + private BooleanArrayList(boolean[] other, int size) {
|
| + array = other;
|
| this.size = size;
|
| }
|
| -
|
| +
|
| @Override
|
| public boolean equals(Object o) {
|
| if (this == o) {
|
| @@ -91,14 +93,14 @@ final class BooleanArrayList
|
| if (size != other.size) {
|
| return false;
|
| }
|
| -
|
| +
|
| final boolean[] arr = other.array;
|
| for (int i = 0; i < size; i++) {
|
| if (array[i] != arr[i]) {
|
| return false;
|
| }
|
| }
|
| -
|
| +
|
| return true;
|
| }
|
|
|
| @@ -170,7 +172,7 @@ final class BooleanArrayList
|
| if (index < 0 || index > size) {
|
| throw new IndexOutOfBoundsException(makeOutOfBoundsExceptionMessage(index));
|
| }
|
| -
|
| +
|
| if (size < array.length) {
|
| // Shift everything over to make room
|
| System.arraycopy(array, index, array, index + 1, size - index);
|
| @@ -178,10 +180,10 @@ final class BooleanArrayList
|
| // Resize to 1.5x the size
|
| int length = ((size * 3) / 2) + 1;
|
| boolean[] newArray = new boolean[length];
|
| -
|
| +
|
| // Copy the first part directly
|
| System.arraycopy(array, 0, newArray, 0, index);
|
| -
|
| +
|
| // Copy the rest shifted over by one to make room
|
| System.arraycopy(array, index, newArray, index + 1, size - index);
|
| array = newArray;
|
| @@ -195,38 +197,38 @@ final class BooleanArrayList
|
| @Override
|
| public boolean addAll(Collection<? extends Boolean> collection) {
|
| ensureIsMutable();
|
| -
|
| +
|
| if (collection == null) {
|
| throw new NullPointerException();
|
| }
|
| -
|
| +
|
| // We specialize when adding another BooleanArrayList to avoid boxing elements.
|
| if (!(collection instanceof BooleanArrayList)) {
|
| return super.addAll(collection);
|
| }
|
| -
|
| +
|
| BooleanArrayList list = (BooleanArrayList) collection;
|
| if (list.size == 0) {
|
| return false;
|
| }
|
| -
|
| +
|
| int overflow = Integer.MAX_VALUE - size;
|
| if (overflow < list.size) {
|
| // We can't actually represent a list this large.
|
| throw new OutOfMemoryError();
|
| }
|
| -
|
| +
|
| int newSize = size + list.size;
|
| if (newSize > array.length) {
|
| array = Arrays.copyOf(array, newSize);
|
| }
|
| -
|
| +
|
| System.arraycopy(list.array, 0, array, size, list.size);
|
| size = newSize;
|
| modCount++;
|
| return true;
|
| }
|
| -
|
| +
|
| @Override
|
| public boolean remove(Object o) {
|
| ensureIsMutable();
|
| @@ -255,7 +257,7 @@ final class BooleanArrayList
|
| /**
|
| * Ensures that the provided {@code index} is within the range of {@code [0, size]}. Throws an
|
| * {@link IndexOutOfBoundsException} if it is not.
|
| - *
|
| + *
|
| * @param index the index to verify is in range
|
| */
|
| private void ensureIndexInRange(int index) {
|
|
|