Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1426)

Unified Diff: third_party/protobuf/java/core/src/main/java/com/google/protobuf/LongArrayList.java

Issue 2600753002: Reverts third_party/protobuf: Update to HEAD (f52e188fe4) (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/java/core/src/main/java/com/google/protobuf/LongArrayList.java
diff --git a/third_party/protobuf/java/core/src/main/java/com/google/protobuf/LongArrayList.java b/third_party/protobuf/java/core/src/main/java/com/google/protobuf/LongArrayList.java
index 5a772e3aa8407ccf9ec14a9c7ea4d96cb7bc3caa..bc4475d11aa916cf79529e18fa636f28eb7bf3e6 100644
--- a/third_party/protobuf/java/core/src/main/java/com/google/protobuf/LongArrayList.java
+++ b/third_party/protobuf/java/core/src/main/java/com/google/protobuf/LongArrayList.java
@@ -38,27 +38,25 @@ import java.util.RandomAccess;
/**
* An implementation of {@link LongList} on top of a primitive array.
- *
+ *
* @author dweis@google.com (Daniel Weis)
*/
-final class LongArrayList
- extends AbstractProtobufList<Long>
- implements LongList, RandomAccess {
-
+final class LongArrayList extends AbstractProtobufList<Long> implements LongList, RandomAccess {
+
private static final LongArrayList EMPTY_LIST = new LongArrayList();
static {
EMPTY_LIST.makeImmutable();
}
-
+
public static LongArrayList emptyList() {
return EMPTY_LIST;
}
-
+
/**
* The backing store for the list.
*/
private long[] array;
-
+
/**
* The size of the list distinct from the length of the array. That is, it is the number of
* elements set in the list.
@@ -73,34 +71,33 @@ final class LongArrayList
}
/**
- * Constructs a new mutable {@code LongArrayList}
- * containing the same elements as {@code other}.
+ * Constructs a new mutable {@code LongArrayList} containing the same elements as {@code other}.
*/
- private LongArrayList(long[] other, int size) {
- array = other;
+ private LongArrayList(long[] array, int size) {
+ this.array = array;
this.size = size;
}
-
+
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (!(o instanceof LongArrayList)) {
+ if (!(o instanceof IntArrayList)) {
return super.equals(o);
}
LongArrayList other = (LongArrayList) o;
if (size != other.size) {
return false;
}
-
+
final long[] arr = other.array;
for (int i = 0; i < size; i++) {
if (array[i] != arr[i]) {
return false;
}
}
-
+
return true;
}
@@ -120,7 +117,7 @@ final class LongArrayList
}
return new LongArrayList(Arrays.copyOf(array, capacity), size);
}
-
+
@Override
public Long get(int index) {
return getLong(index);
@@ -172,7 +169,7 @@ final class LongArrayList
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);
@@ -180,10 +177,10 @@ final class LongArrayList
// Resize to 1.5x the size
int length = ((size * 3) / 2) + 1;
long[] newArray = new long[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;
@@ -197,38 +194,38 @@ final class LongArrayList
@Override
public boolean addAll(Collection<? extends Long> collection) {
ensureIsMutable();
-
+
if (collection == null) {
throw new NullPointerException();
}
-
+
// We specialize when adding another LongArrayList to avoid boxing elements.
if (!(collection instanceof LongArrayList)) {
return super.addAll(collection);
}
-
+
LongArrayList list = (LongArrayList) 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();
@@ -257,7 +254,7 @@ final class LongArrayList
/**
* 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) {

Powered by Google App Engine
This is Rietveld 408576698