diff options
Diffstat (limited to 'chromium/third_party/protobuf/java/src/main/java')
5 files changed, 17 insertions, 15 deletions
diff --git a/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/ByteString.java b/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/ByteString.java index 73d831f6eec..1b18169e9e1 100644 --- a/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/ByteString.java +++ b/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/ByteString.java @@ -37,6 +37,7 @@ import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -775,15 +776,6 @@ public abstract class ByteString implements Iterable<Byte> { flushLastBuffer(); return ByteString.copyFrom(flushedBuffers); } - - /** - * Implement java.util.Arrays.copyOf() for jdk 1.5. - */ - private byte[] copyArray(byte[] buffer, int length) { - byte[] result = new byte[length]; - System.arraycopy(buffer, 0, result, 0, Math.min(buffer.length, length)); - return result; - } /** * Writes the complete contents of this byte array output stream to @@ -808,7 +800,7 @@ public abstract class ByteString implements Iterable<Byte> { byteString.writeTo(out); } - out.write(copyArray(cachedBuffer, cachedBufferPos)); + out.write(Arrays.copyOf(cachedBuffer, cachedBufferPos)); } /** @@ -861,7 +853,7 @@ public abstract class ByteString implements Iterable<Byte> { private void flushLastBuffer() { if (bufferPos < buffer.length) { if (bufferPos > 0) { - byte[] bufferCopy = copyArray(buffer, bufferPos); + byte[] bufferCopy = Arrays.copyOf(buffer, bufferPos); flushedBuffers.add(new LiteralByteString(bufferCopy)); } // We reuse this buffer for further writes. diff --git a/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/LazyField.java b/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/LazyField.java index c4f9201cdc2..df9425eb360 100644 --- a/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/LazyField.java +++ b/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/LazyField.java @@ -157,10 +157,12 @@ class LazyField { this.entry = entry; } + @Override public K getKey() { return entry.getKey(); } + @Override public Object getValue() { LazyField field = entry.getValue(); if (field == null) { @@ -173,6 +175,7 @@ class LazyField { return entry.getValue(); } + @Override public Object setValue(Object value) { if (!(value instanceof MessageLite)) { throw new IllegalArgumentException( @@ -190,11 +193,13 @@ class LazyField { this.iterator = iterator; } + @Override public boolean hasNext() { return iterator.hasNext(); } @SuppressWarnings("unchecked") + @Override public Entry<K, Object> next() { Entry<K, ?> entry = iterator.next(); if (entry.getValue() instanceof LazyField) { @@ -203,6 +208,7 @@ class LazyField { return (Entry<K, Object>) entry; } + @Override public void remove() { iterator.remove(); } diff --git a/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/LazyStringArrayList.java b/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/LazyStringArrayList.java index a5f0bd901fd..75c6a4b73d3 100644 --- a/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/LazyStringArrayList.java +++ b/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/LazyStringArrayList.java @@ -172,6 +172,7 @@ public class LazyStringArrayList extends AbstractList<String> } } + @Override public List<?> getUnderlyingElements() { return Collections.unmodifiableList(list); } diff --git a/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/RopeByteString.java b/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/RopeByteString.java index 46997823469..8d44d117723 100644 --- a/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/RopeByteString.java +++ b/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/RopeByteString.java @@ -36,12 +36,13 @@ import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.io.ByteArrayInputStream; import java.nio.ByteBuffer; +import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; +import java.util.Deque; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; -import java.util.Stack; /** * Class to represent {@code ByteStrings} formed by concatenation of other @@ -589,7 +590,8 @@ class RopeByteString extends ByteString { // Stack containing the part of the string, starting from the left, that // we've already traversed. The final string should be the equivalent of // concatenating the strings on the stack from bottom to top. - private final Stack<ByteString> prefixesStack = new Stack<ByteString>(); + private final Deque<ByteString> prefixesStack = + new ArrayDeque<ByteString>(minLengthByDepth.length); private ByteString balance(ByteString left, ByteString right) { doBalance(left); @@ -701,8 +703,8 @@ class RopeByteString extends ByteString { */ private static class PieceIterator implements Iterator<LiteralByteString> { - private final Stack<RopeByteString> breadCrumbs = - new Stack<RopeByteString>(); + private final Deque<RopeByteString> breadCrumbs = + new ArrayDeque<RopeByteString>(minLengthByDepth.length); private LiteralByteString next; private PieceIterator(ByteString root) { diff --git a/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java b/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java index 591bca54091..f80f09680bb 100644 --- a/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java +++ b/chromium/third_party/protobuf/java/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java @@ -145,6 +145,7 @@ public class UnmodifiableLazyStringList extends AbstractList<String> }; } + @Override public List<?> getUnderlyingElements() { // The returned value is already unmodifiable. return list.getUnderlyingElements(); |