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

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

Issue 1983203003: Update third_party/protobuf to protobuf-v3.0.0-beta-3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: owners Created 4 years, 7 months 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/ProtobufArrayList.java
diff --git a/third_party/protobuf/java/src/main/java/com/google/protobuf/ProtobufArrayList.java b/third_party/protobuf/java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java
similarity index 85%
copy from third_party/protobuf/java/src/main/java/com/google/protobuf/ProtobufArrayList.java
copy to third_party/protobuf/java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java
index d2f82ac5135b3664770afc8968c6fd5873541f70..81255ec29125ba032f52b114f914b00f20a8e978 100644
--- a/third_party/protobuf/java/src/main/java/com/google/protobuf/ProtobufArrayList.java
+++ b/third_party/protobuf/java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java
@@ -38,7 +38,7 @@ import java.util.List;
/**
* Implements {@link ProtobufList} for non-primitive and {@link String} types.
*/
-class ProtobufArrayList<E> extends AbstractProtobufList<E> {
+final class ProtobufArrayList<E> extends AbstractProtobufList<E> {
private static final ProtobufArrayList<Object> EMPTY_LIST = new ProtobufArrayList<Object>();
static {
@@ -51,17 +51,23 @@ class ProtobufArrayList<E> extends AbstractProtobufList<E> {
}
private final List<E> list;
-
+
ProtobufArrayList() {
- list = new ArrayList<E>();
+ this(new ArrayList<E>(DEFAULT_CAPACITY));
}
- ProtobufArrayList(List<E> toCopy) {
- list = new ArrayList<E>(toCopy);
+ private ProtobufArrayList(List<E> list) {
+ this.list = list;
}
-
- ProtobufArrayList(int capacity) {
- list = new ArrayList<E>(capacity);
+
+ @Override
+ public ProtobufArrayList<E> mutableCopyWithCapacity(int capacity) {
+ if (capacity < size()) {
+ throw new IllegalArgumentException();
+ }
+ List<E> newList = new ArrayList<E>(capacity);
+ newList.addAll(list);
+ return new ProtobufArrayList<E>(newList);
}
@Override

Powered by Google App Engine
This is Rietveld 408576698