| Index: third_party/protobuf/java/core/src/main/java/com/google/protobuf/RopeByteString.java
|
| diff --git a/third_party/protobuf/java/src/main/java/com/google/protobuf/RopeByteString.java b/third_party/protobuf/java/core/src/main/java/com/google/protobuf/RopeByteString.java
|
| similarity index 96%
|
| rename from third_party/protobuf/java/src/main/java/com/google/protobuf/RopeByteString.java
|
| rename to third_party/protobuf/java/core/src/main/java/com/google/protobuf/RopeByteString.java
|
| index 6e8eb724c65bc44bf197eed3977fcb29499d8d77..3f3e9bd15eaa08994cb13122efdafa3d3638aed8 100644
|
| --- a/third_party/protobuf/java/src/main/java/com/google/protobuf/RopeByteString.java
|
| +++ b/third_party/protobuf/java/core/src/main/java/com/google/protobuf/RopeByteString.java
|
| @@ -48,10 +48,11 @@ import java.util.Stack;
|
| /**
|
| * Class to represent {@code ByteStrings} formed by concatenation of other
|
| * ByteStrings, without copying the data in the pieces. The concatenation is
|
| - * represented as a tree whose leaf nodes are each a {@link LiteralByteString}.
|
| + * represented as a tree whose leaf nodes are each a
|
| + * {@link com.google.protobuf.ByteString.LeafByteString}.
|
| *
|
| * <p>Most of the operation here is inspired by the now-famous paper <a
|
| - * href="http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol25/issue12/spe986.pdf">
|
| + * href="https://web.archive.org/web/20060202015456/http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol25/issue12/spe986.pdf">
|
| * BAP95 </a> Ropes: an Alternative to Strings hans-j. boehm, russ atkinson and
|
| * michael plass
|
| *
|
| @@ -139,8 +140,9 @@ final class RopeByteString extends ByteString {
|
| /**
|
| * Concatenate the given strings while performing various optimizations to
|
| * slow the growth rate of tree depth and tree node count. The result is
|
| - * either a {@link LiteralByteString} or a {@link RopeByteString}
|
| - * depending on which optimizations, if any, were applied.
|
| + * either a {@link com.google.protobuf.ByteString.LeafByteString} or a
|
| + * {@link RopeByteString} depending on which optimizations, if any, were
|
| + * applied.
|
| *
|
| * <p>Small pieces of length less than {@link
|
| * ByteString#CONCATENATE_BY_COPY_SIZE} may be copied by value here, as in
|
| @@ -187,7 +189,7 @@ final class RopeByteString extends ByteString {
|
| && leftRope.getTreeDepth() > right.getTreeDepth()) {
|
| // Typically for concatenate-built strings the left-side is deeper than
|
| // the right. This is our final attempt to concatenate without
|
| - // increasing the tree depth. We'll redo the the node on the RHS. This
|
| + // increasing the tree depth. We'll redo the node on the RHS. This
|
| // is yet another optimization for building the string by repeatedly
|
| // concatenating on the right.
|
| ByteString newRight = new RopeByteString(leftRope.right, right);
|
| @@ -213,14 +215,14 @@ final class RopeByteString extends ByteString {
|
| * @param right string on the right
|
| * @return string formed by copying data bytes
|
| */
|
| - private static LiteralByteString concatenateBytes(ByteString left,
|
| + private static ByteString concatenateBytes(ByteString left,
|
| ByteString right) {
|
| int leftSize = left.size();
|
| int rightSize = right.size();
|
| byte[] bytes = new byte[leftSize + rightSize];
|
| left.copyTo(bytes, 0, 0, leftSize);
|
| right.copyTo(bytes, 0, leftSize, rightSize);
|
| - return new LiteralByteString(bytes); // Constructor wraps bytes
|
| + return ByteString.wrap(bytes); // Constructor wraps bytes
|
| }
|
|
|
| /**
|
| @@ -294,8 +296,7 @@ final class RopeByteString extends ByteString {
|
| *
|
| * <p>Substrings of {@code length < 2} should result in at most a single
|
| * recursive call chain, terminating at a leaf node. Thus the result will be a
|
| - * {@link LiteralByteString}. {@link #RopeByteString(ByteString,
|
| - * ByteString)}.
|
| + * {@link com.google.protobuf.ByteString.LeafByteString}.
|
| *
|
| * @param beginIndex start at this index
|
| * @param endIndex the last character is the one before this index
|
| @@ -368,7 +369,7 @@ final class RopeByteString extends ByteString {
|
|
|
| @Override
|
| public List<ByteBuffer> asReadOnlyByteBufferList() {
|
| - // Walk through the list of LiteralByteString's that make up this
|
| + // Walk through the list of LeafByteString's that make up this
|
| // rope, and add each one as a read-only ByteBuffer.
|
| List<ByteBuffer> result = new ArrayList<ByteBuffer>();
|
| PieceIterator pieces = new PieceIterator(this);
|
| @@ -400,6 +401,12 @@ final class RopeByteString extends ByteString {
|
| }
|
|
|
| @Override
|
| + void writeTo(ByteOutput output) throws IOException {
|
| + left.writeTo(output);
|
| + right.writeTo(output);
|
| + }
|
| +
|
| + @Override
|
| protected String toStringInternal(Charset charset) {
|
| return new String(toByteArray(), charset);
|
| }
|
| @@ -709,9 +716,10 @@ final class RopeByteString extends ByteString {
|
| }
|
|
|
| /**
|
| - * Returns the next item and advances one {@code LiteralByteString}.
|
| + * Returns the next item and advances one
|
| + * {@link com.google.protobuf.ByteString.LeafByteString}.
|
| *
|
| - * @return next non-empty LiteralByteString or {@code null}
|
| + * @return next non-empty LeafByteString or {@code null}
|
| */
|
| @Override
|
| public LeafByteString next() {
|
| @@ -735,7 +743,7 @@ final class RopeByteString extends ByteString {
|
| private static final long serialVersionUID = 1L;
|
|
|
| Object writeReplace() {
|
| - return new LiteralByteString(toByteArray());
|
| + return ByteString.wrap(toByteArray());
|
| }
|
|
|
| private void readObject(@SuppressWarnings("unused") ObjectInputStream in) throws IOException {
|
|
|