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 |