31 package com.google.protobuf;
41 import java.io.ByteArrayOutputStream;
42 import java.io.IOException;
43 import java.io.InputStream;
44 import java.nio.ByteBuffer;
45 import java.util.ArrayList;
46 import java.util.Arrays;
47 import java.util.Iterator;
48 import java.util.List;
76 CodedInputStreamReader wrapper;
85 if (bufferSize <= 0) {
86 throw new IllegalArgumentException(
"bufferSize must be > 0");
105 final Iterable<ByteBuffer>
bufs,
final boolean bufferIsImmutable) {
115 totalSize +=
buf.remaining();
116 if (
buf.hasArray()) {
118 }
else if (
buf.isDirect()) {
125 return new IterableDirectByteBufferDecoder(
bufs, totalSize, bufferIsImmutable);
144 final byte[]
buf,
final int off,
final int len,
final boolean bufferIsImmutable) {
145 ArrayDecoder result =
new ArrayDecoder(
buf, off,
len, bufferIsImmutable);
152 result.pushLimit(
len);
153 }
catch (InvalidProtocolBufferException ex) {
161 throw new IllegalArgumentException(ex);
180 if (
buf.hasArray()) {
182 buf.array(),
buf.arrayOffset() +
buf.position(),
buf.remaining(), bufferIsImmutable);
185 if (
buf.isDirect() && UnsafeDirectNioDecoder.isSupported()) {
186 return new UnsafeDirectNioDecoder(
buf, bufferIsImmutable);
192 byte[]
buffer =
new byte[
buf.remaining()];
207 public abstract int readTag() throws IOException;
225 public abstract
boolean skipField(final
int tag) throws IOException;
243 public abstract
void skipMessage() throws IOException;
255 public abstract
double readDouble() throws IOException;
258 public abstract
float readFloat() throws IOException;
261 public abstract
long readUInt64() throws IOException;
264 public abstract
long readInt64() throws IOException;
267 public abstract
int readInt32() throws IOException;
270 public abstract
long readFixed64() throws IOException;
273 public abstract
int readFixed32() throws IOException;
276 public abstract
boolean readBool() throws IOException;
282 public abstract String
readString() throws IOException;
292 final
int fieldNumber,
334 public abstract
int readUInt32() throws IOException;
340 public abstract
int readEnum() throws IOException;
349 public abstract
int readSInt32() throws IOException;
352 public abstract
long readSInt64() throws IOException;
364 abstract
long readRawVarint64SlowPath() throws IOException;
389 throw new IllegalArgumentException(
"Recursion limit cannot be negative: " + limit);
391 final int oldLimit = recursionLimit;
392 recursionLimit = limit;
412 throw new IllegalArgumentException(
"Size limit cannot be negative: " + limit);
414 final int oldLimit = sizeLimit;
429 final void discardUnknownFields() {
437 final void unsetDiscardUnknownFields() {
468 public abstract int pushLimit(
int byteLimit)
throws InvalidProtocolBufferException;
475 public abstract void popLimit(
final int oldLimit);
488 public abstract boolean isAtEnd() throws IOException;
501 public abstract
byte readRawByte() throws IOException;
527 return (
n >>> 1) ^ -(
n & 1);
540 return (
n >>> 1) ^ -(
n & 1);
549 if ((firstByte & 0x80) == 0) {
553 int result = firstByte & 0x7f;
556 final int b =
input.read();
560 result |= (
b & 0x7f) <<
offset;
561 if ((
b & 0x80) == 0) {
567 final int b =
input.read();
571 if ((
b & 0x80) == 0) {
585 final int firstByte =
input.read();
586 if (firstByte == -1) {
643 public boolean skipField(
final int tag)
throws IOException {
675 output.writeRawVarint32(tag);
682 output.writeRawVarint32(tag);
689 output.writeRawVarint32(tag);
695 output.writeRawVarint32(tag);
701 output.writeRawVarint32(endtag);
711 output.writeRawVarint32(tag);
823 final int fieldNumber,
827 if (recursionDepth >= recursionLimit) {
831 builder.mergeFrom(
this, extensionRegistry);
839 final int fieldNumber,
843 if (recursionDepth >= recursionLimit) {
847 T result =
parser.parsePartialFrom(
this, extensionRegistry);
865 if (recursionDepth >= recursionLimit) {
870 builder.mergeFrom(
this, extensionRegistry);
881 if (recursionDepth >= recursionLimit) {
886 T result =
parser.parsePartialFrom(
this, extensionRegistry);
938 return EMPTY_BYTE_BUFFER;
985 if (
limit == tempPos) {
991 if ((x =
buffer[tempPos++]) >= 0) {
994 }
else if (
limit - tempPos < 9) {
996 }
else if ((
x ^= (
buffer[tempPos++] << 7)) < 0) {
998 }
else if ((
x ^= (
buffer[tempPos++] << 14)) >= 0) {
999 x ^= (~0 << 7) ^ (~0 << 14);
1000 }
else if ((
x ^= (
buffer[tempPos++] << 21)) < 0) {
1001 x ^= (~0 << 7) ^ (~0 << 14) ^ (~0 << 21);
1005 x ^= (~0 << 7) ^ (~0 << 14) ^ (~0 << 21) ^ (~0 << 28);
1011 &&
buffer[tempPos++] < 0) {
1018 return (
int) readRawVarint64SlowPath();
1022 if (
limit -
pos >= MAX_VARINT_SIZE) {
1030 for (
int i = 0;
i < MAX_VARINT_SIZE;
i++) {
1039 for (
int i = 0;
i < MAX_VARINT_SIZE;
i++) {
1064 if (
limit == tempPos) {
1071 if ((y =
buffer[tempPos++]) >= 0) {
1074 }
else if (
limit - tempPos < 9) {
1076 }
else if ((
y ^= (
buffer[tempPos++] << 7)) < 0) {
1078 }
else if ((
y ^= (
buffer[tempPos++] << 14)) >= 0) {
1079 x =
y ^ ((~0 << 7) ^ (~0 << 14));
1080 }
else if ((
y ^= (
buffer[tempPos++] << 21)) < 0) {
1081 x =
y ^ ((~0 << 7) ^ (~0 << 14) ^ (~0 << 21));
1082 }
else if ((
x =
y ^ ((
long)
buffer[tempPos++] << 28)) >= 0L) {
1083 x ^= (~0L << 7) ^ (~0L << 14) ^ (~0L << 21) ^ (~0L << 28);
1084 }
else if ((
x ^= ((
long)
buffer[tempPos++] << 35)) < 0L) {
1085 x ^= (~0L << 7) ^ (~0L << 14) ^ (~0L << 21) ^ (~0L << 28) ^ (~0L << 35);
1086 }
else if ((
x ^= ((
long)
buffer[tempPos++] << 42)) >= 0L) {
1087 x ^= (~0L << 7) ^ (~0L << 14) ^ (~0L << 21) ^ (~0L << 28) ^ (~0L << 35) ^ (~0L << 42);
1088 }
else if ((
x ^= ((
long)
buffer[tempPos++] << 49)) < 0L) {
1109 if (
buffer[tempPos++] < 0L) {
1117 return readRawVarint64SlowPath();
1121 long readRawVarint64SlowPath() throws IOException {
1123 for (
int shift = 0; shift < 64; shift += 7) {
1125 result |= (
long) (
b & 0x7F) << shift;
1126 if ((
b & 0x80) == 0) {
1130 throw InvalidProtocolBufferException.malformedVarint();
1137 if (
limit - tempPos < FIXED32_SIZE) {
1142 pos = tempPos + FIXED32_SIZE;
1143 return (((
buffer[tempPos] & 0xff))
1144 | ((
buffer[tempPos + 1] & 0xff) << 8)
1145 | ((
buffer[tempPos + 2] & 0xff) << 16)
1146 | ((
buffer[tempPos + 3] & 0xff) << 24));
1153 if (
limit - tempPos < FIXED64_SIZE) {
1158 pos = tempPos + FIXED64_SIZE;
1159 return (((
buffer[tempPos] & 0xffL))
1160 | ((
buffer[tempPos + 1] & 0xffL) << 8)
1161 | ((
buffer[tempPos + 2] & 0xffL) << 16)
1162 | ((
buffer[tempPos + 3] & 0xffL) << 24)
1163 | ((
buffer[tempPos + 4] & 0xffL) << 32)
1164 | ((
buffer[tempPos + 5] & 0xffL) << 40)
1165 | ((
buffer[tempPos + 6] & 0xffL) << 48)
1166 | ((
buffer[tempPos + 7] & 0xffL) << 56));
1171 this.enableAliasing =
enabled;
1181 if (byteLimit < 0) {
1186 if (byteLimit > oldLimit) {
1244 final int tempPos =
pos;
1246 return Arrays.copyOfRange(
buffer, tempPos,
pos);
1315 static boolean isSupported() {
1316 return UnsafeUtil.hasUnsafeByteBufferOperations();
1357 public boolean skipField(
final int tag)
throws IOException {
1389 output.writeRawVarint32(tag);
1396 output.writeRawVarint32(tag);
1403 output.writeRawVarint32(tag);
1409 output.writeRawVarint32(tag);
1415 output.writeRawVarint32(endtag);
1425 output.writeRawVarint32(tag);
1507 String result =
new String(
bytes, UTF_8);
1542 final int fieldNumber,
1545 throws IOException {
1546 if (recursionDepth >= recursionLimit) {
1550 builder.mergeFrom(
this, extensionRegistry);
1558 final int fieldNumber,
1561 throws IOException {
1562 if (recursionDepth >= recursionLimit) {
1566 T result =
parser.parsePartialFrom(
this, extensionRegistry);
1575 throws IOException {
1582 throws IOException {
1584 if (recursionDepth >= recursionLimit) {
1589 builder.mergeFrom(
this, extensionRegistry);
1600 if (recursionDepth >= recursionLimit) {
1605 T result =
parser.parsePartialFrom(
this, extensionRegistry);
1659 return ByteBuffer.wrap(
bytes);
1665 return EMPTY_BYTE_BUFFER;
1712 if (
limit == tempPos) {
1717 if ((
x = UnsafeUtil.getByte(tempPos++)) >= 0) {
1720 }
else if (
limit - tempPos < 9) {
1722 }
else if ((
x ^= (UnsafeUtil.getByte(tempPos++) << 7)) < 0) {
1724 }
else if ((
x ^= (UnsafeUtil.getByte(tempPos++) << 14)) >= 0) {
1725 x ^= (~0 << 7) ^ (~0 << 14);
1726 }
else if ((
x ^= (UnsafeUtil.getByte(tempPos++) << 21)) < 0) {
1727 x ^= (~0 << 7) ^ (~0 << 14) ^ (~0 << 21);
1729 int y = UnsafeUtil.getByte(tempPos++);
1731 x ^= (~0 << 7) ^ (~0 << 14) ^ (~0 << 21) ^ (~0 << 28);
1733 && UnsafeUtil.getByte(tempPos++) < 0
1734 && UnsafeUtil.getByte(tempPos++) < 0
1735 && UnsafeUtil.getByte(tempPos++) < 0
1736 && UnsafeUtil.getByte(tempPos++) < 0
1737 && UnsafeUtil.getByte(tempPos++) < 0) {
1744 return (
int) readRawVarint64SlowPath();
1756 for (
int i = 0;
i < MAX_VARINT_SIZE;
i++) {
1757 if (UnsafeUtil.getByte(
pos++) >= 0) {
1765 for (
int i = 0;
i < MAX_VARINT_SIZE;
i++) {
1790 if (
limit == tempPos) {
1796 if ((
y = UnsafeUtil.getByte(tempPos++)) >= 0) {
1799 }
else if (
limit - tempPos < 9) {
1801 }
else if ((
y ^= (UnsafeUtil.getByte(tempPos++) << 7)) < 0) {
1803 }
else if ((
y ^= (UnsafeUtil.getByte(tempPos++) << 14)) >= 0) {
1804 x =
y ^ ((~0 << 7) ^ (~0 << 14));
1805 }
else if ((
y ^= (UnsafeUtil.getByte(tempPos++) << 21)) < 0) {
1806 x =
y ^ ((~0 << 7) ^ (~0 << 14) ^ (~0 << 21));
1807 }
else if ((
x =
y ^ ((
long) UnsafeUtil.getByte(tempPos++) << 28)) >= 0L) {
1808 x ^= (~0L << 7) ^ (~0L << 14) ^ (~0L << 21) ^ (~0L << 28);
1809 }
else if ((
x ^= ((
long) UnsafeUtil.getByte(tempPos++) << 35)) < 0L) {
1810 x ^= (~0L << 7) ^ (~0L << 14) ^ (~0L << 21) ^ (~0L << 28) ^ (~0L << 35);
1811 }
else if ((
x ^= ((
long) UnsafeUtil.getByte(tempPos++) << 42)) >= 0L) {
1812 x ^= (~0L << 7) ^ (~0L << 14) ^ (~0L << 21) ^ (~0L << 28) ^ (~0L << 35) ^ (~0L << 42);
1813 }
else if ((
x ^= ((
long) UnsafeUtil.getByte(tempPos++) << 49)) < 0L) {
1823 x ^= ((
long) UnsafeUtil.getByte(tempPos++) << 56);
1834 if (UnsafeUtil.getByte(tempPos++) < 0L) {
1842 return readRawVarint64SlowPath();
1846 long readRawVarint64SlowPath() throws IOException {
1848 for (
int shift = 0; shift < 64; shift += 7) {
1850 result |= (
long) (
b & 0x7F) << shift;
1851 if ((
b & 0x80) == 0) {
1855 throw InvalidProtocolBufferException.malformedVarint();
1862 if (
limit - tempPos < FIXED32_SIZE) {
1866 pos = tempPos + FIXED32_SIZE;
1867 return (((UnsafeUtil.getByte(tempPos) & 0xff))
1868 | ((UnsafeUtil.getByte(tempPos + 1) & 0xff) << 8)
1869 | ((UnsafeUtil.getByte(tempPos + 2) & 0xff) << 16)
1870 | ((UnsafeUtil.getByte(tempPos + 3) & 0xff) << 24));
1877 if (
limit - tempPos < FIXED64_SIZE) {
1881 pos = tempPos + FIXED64_SIZE;
1882 return (((UnsafeUtil.getByte(tempPos) & 0xffL))
1883 | ((UnsafeUtil.getByte(tempPos + 1) & 0xffL) << 8)
1884 | ((UnsafeUtil.getByte(tempPos + 2) & 0xffL) << 16)
1885 | ((UnsafeUtil.getByte(tempPos + 3) & 0xffL) << 24)
1886 | ((UnsafeUtil.getByte(tempPos + 4) & 0xffL) << 32)
1887 | ((UnsafeUtil.getByte(tempPos + 5) & 0xffL) << 40)
1888 | ((UnsafeUtil.getByte(tempPos + 6) & 0xffL) << 48)
1889 | ((UnsafeUtil.getByte(tempPos + 7) & 0xffL) << 56));
1894 this.enableAliasing =
enabled;
1904 if (byteLimit < 0) {
1909 if (byteLimit > oldLimit) {
1949 return UnsafeUtil.getByte(
pos++);
1963 return EMPTY_BYTE_ARRAY;
2007 int prevPos =
buffer.position();
2008 int prevLimit =
buffer.limit();
2013 }
catch (IllegalArgumentException e) {
2016 buffer.position(prevPos);
2047 checkNotNull(
input,
"input");
2050 this.bufferSize = 0;
2084 public boolean skipField(
final int tag)
throws IOException {
2116 output.writeRawVarint32(tag);
2123 output.writeRawVarint32(tag);
2130 output.writeRawVarint32(tag);
2136 output.writeRawVarint32(tag);
2142 output.writeRawVarint32(endtag);
2152 output.writeRawVarint32(tag);
2196 ByteBuffer getSkippedData() {
2276 final int oldPos =
pos;
2284 }
else if (
size == 0) {
2296 return Utf8.decodeUtf8(
bytes, tempPos,
size);
2301 final int fieldNumber,
2304 throws IOException {
2305 if (recursionDepth >= recursionLimit) {
2309 builder.mergeFrom(
this, extensionRegistry);
2317 final int fieldNumber,
2320 throws IOException {
2321 if (recursionDepth >= recursionLimit) {
2325 T result =
parser.parsePartialFrom(
this, extensionRegistry);
2334 throws IOException {
2341 throws IOException {
2343 if (recursionDepth >= recursionLimit) {
2348 builder.mergeFrom(
this, extensionRegistry);
2359 if (recursionDepth >= recursionLimit) {
2364 T result =
parser.parsePartialFrom(
this, extensionRegistry);
2408 ByteBuffer result = ByteBuffer.wrap(Arrays.copyOfRange(
buffer,
pos,
pos +
size));
2467 if ((x =
buffer[tempPos++]) >= 0) {
2472 }
else if ((
x ^= (
buffer[tempPos++] << 7)) < 0) {
2474 }
else if ((
x ^= (
buffer[tempPos++] << 14)) >= 0) {
2475 x ^= (~0 << 7) ^ (~0 << 14);
2476 }
else if ((
x ^= (
buffer[tempPos++] << 21)) < 0) {
2477 x ^= (~0 << 7) ^ (~0 << 14) ^ (~0 << 21);
2481 x ^= (~0 << 7) ^ (~0 << 14) ^ (~0 << 21) ^ (~0 << 28);
2487 &&
buffer[tempPos++] < 0) {
2494 return (
int) readRawVarint64SlowPath();
2506 for (
int i = 0;
i < MAX_VARINT_SIZE;
i++) {
2515 for (
int i = 0;
i < MAX_VARINT_SIZE;
i++) {
2547 if ((y =
buffer[tempPos++]) >= 0) {
2552 }
else if ((
y ^= (
buffer[tempPos++] << 7)) < 0) {
2554 }
else if ((
y ^= (
buffer[tempPos++] << 14)) >= 0) {
2555 x =
y ^ ((~0 << 7) ^ (~0 << 14));
2556 }
else if ((
y ^= (
buffer[tempPos++] << 21)) < 0) {
2557 x =
y ^ ((~0 << 7) ^ (~0 << 14) ^ (~0 << 21));
2558 }
else if ((
x =
y ^ ((
long)
buffer[tempPos++] << 28)) >= 0L) {
2559 x ^= (~0L << 7) ^ (~0L << 14) ^ (~0L << 21) ^ (~0L << 28);
2560 }
else if ((
x ^= ((
long)
buffer[tempPos++] << 35)) < 0L) {
2561 x ^= (~0L << 7) ^ (~0L << 14) ^ (~0L << 21) ^ (~0L << 28) ^ (~0L << 35);
2562 }
else if ((
x ^= ((
long)
buffer[tempPos++] << 42)) >= 0L) {
2563 x ^= (~0L << 7) ^ (~0L << 14) ^ (~0L << 21) ^ (~0L << 28) ^ (~0L << 35) ^ (~0L << 42);
2564 }
else if ((
x ^= ((
long)
buffer[tempPos++] << 49)) < 0L) {
2585 if (
buffer[tempPos++] < 0L) {
2593 return readRawVarint64SlowPath();
2597 long readRawVarint64SlowPath() throws IOException {
2599 for (
int shift = 0; shift < 64; shift += 7) {
2601 result |= (
long) (
b & 0x7F) << shift;
2602 if ((
b & 0x80) == 0) {
2606 throw InvalidProtocolBufferException.malformedVarint();
2619 pos = tempPos + FIXED32_SIZE;
2620 return (((
buffer[tempPos] & 0xff))
2621 | ((
buffer[tempPos + 1] & 0xff) << 8)
2622 | ((
buffer[tempPos + 2] & 0xff) << 16)
2623 | ((
buffer[tempPos + 3] & 0xff) << 24));
2636 pos = tempPos + FIXED64_SIZE;
2637 return (((
buffer[tempPos] & 0xffL))
2638 | ((
buffer[tempPos + 1] & 0xffL) << 8)
2639 | ((
buffer[tempPos + 2] & 0xffL) << 16)
2640 | ((
buffer[tempPos + 3] & 0xffL) << 24)
2641 | ((
buffer[tempPos + 4] & 0xffL) << 32)
2642 | ((
buffer[tempPos + 5] & 0xffL) << 40)
2643 | ((
buffer[tempPos + 6] & 0xffL) << 48)
2644 | ((
buffer[tempPos + 7] & 0xffL) << 56));
2661 if (byteLimit < 0) {
2666 if (byteLimit > oldLimit) {
2750 throw new IllegalStateException(
2751 "refillBuffer() called when " +
n +
" bytes were already available in buffer");
2791 if (bytesRead == 0 || bytesRead < -1 || bytesRead >
buffer.
length) {
2792 throw new IllegalStateException(
2794 +
"#read(byte[]) returned invalid result: "
2796 +
"\nThe InputStream implementation is buggy.");
2798 if (bytesRead > 0) {
2817 final int tempPos =
pos;
2820 return Arrays.copyOfRange(
buffer, tempPos, tempPos +
size);
2835 final int size,
boolean ensureNoLeakedReferences)
throws IOException {
2838 if (result !=
null) {
2839 return ensureNoLeakedReferences ? result.clone() : result;
2842 final int originalBufferPos =
pos;
2851 int sizeLeft =
size - bufferedBytes;
2861 System.arraycopy(
buffer, originalBufferPos,
bytes, 0, bufferedBytes);
2864 int tempPos = bufferedBytes;
2865 for (
final byte[] chunk : chunks) {
2866 System.arraycopy(chunk, 0,
bytes, tempPos, chunk.length);
2867 tempPos += chunk.length;
2890 if (currentMessageSize - sizeLimit > 0) {
2903 int sizeLeft =
size - bufferedBytes;
2917 int tempPos = bufferedBytes;
2918 while (tempPos <
bytes.length) {
2946 final List<byte[]> chunks =
new ArrayList<byte[]>();
2948 while (sizeLeft > 0) {
2952 while (tempPos < chunk.length) {
2953 final int n =
input.read(chunk, tempPos, chunk.length - tempPos);
2960 sizeLeft -= chunk.length;
2973 if (result !=
null) {
2979 final int originalBufferPos =
pos;
2988 int sizeLeft =
size - bufferedBytes;
2998 System.arraycopy(
buffer, originalBufferPos,
bytes, 0, bufferedBytes);
3001 int tempPos = bufferedBytes;
3002 for (
final byte[] chunk : chunks) {
3003 System.arraycopy(chunk, 0,
bytes, tempPos, chunk.length);
3004 tempPos += chunk.length;
3036 int totalSkipped = 0;
3045 while (totalSkipped <
size) {
3046 int toSkip =
size - totalSkipped;
3047 long skipped =
input.skip(toSkip);
3048 if (skipped < 0 || skipped > toSkip) {
3049 throw new IllegalStateException(
3051 +
"#skip returned invalid result: "
3053 +
"\nThe InputStream implementation is buggy.");
3054 }
else if (skipped == 0) {
3061 totalSkipped += (int) skipped;
3068 if (totalSkipped <
size) {
3140 Iterable<ByteBuffer> inputBufs,
int size,
boolean immutableFlag) {
3206 public boolean skipField(
final int tag)
throws IOException {
3238 output.writeRawVarint32(tag);
3245 output.writeRawVarint32(tag);
3252 output.writeRawVarint32(tag);
3258 output.writeRawVarint32(tag);
3264 output.writeRawVarint32(endtag);
3274 output.writeRawVarint32(tag);
3351 String result =
new String(
bytes, UTF_8);
3358 String result =
new String(
bytes, UTF_8);
3397 final int fieldNumber,
3400 throws IOException {
3401 if (recursionDepth >= recursionLimit) {
3405 builder.mergeFrom(
this, extensionRegistry);
3413 final int fieldNumber,
3416 throws IOException {
3417 if (recursionDepth >= recursionLimit) {
3421 T result =
parser.parsePartialFrom(
this, extensionRegistry);
3430 throws IOException {
3437 throws IOException {
3439 if (recursionDepth >= recursionLimit) {
3444 builder.mergeFrom(
this, extensionRegistry);
3455 if (recursionDepth >= recursionLimit) {
3460 T result =
parser.parsePartialFrom(
this, extensionRegistry);
3484 byte[] temp =
new byte[
size];
3516 return ByteBuffer.wrap(
bytes);
3519 byte[] temp =
new byte[
size];
3521 return ByteBuffer.wrap(temp);
3525 return EMPTY_BYTE_BUFFER;
3574 if ((
x = UnsafeUtil.getByte(tempPos++)) >= 0) {
3579 }
else if ((
x ^= (UnsafeUtil.getByte(tempPos++) << 7)) < 0) {
3581 }
else if ((
x ^= (UnsafeUtil.getByte(tempPos++) << 14)) >= 0) {
3582 x ^= (~0 << 7) ^ (~0 << 14);
3583 }
else if ((
x ^= (UnsafeUtil.getByte(tempPos++) << 21)) < 0) {
3584 x ^= (~0 << 7) ^ (~0 << 14) ^ (~0 << 21);
3586 int y = UnsafeUtil.getByte(tempPos++);
3588 x ^= (~0 << 7) ^ (~0 << 14) ^ (~0 << 21) ^ (~0 << 28);
3590 && UnsafeUtil.getByte(tempPos++) < 0
3591 && UnsafeUtil.getByte(tempPos++) < 0
3592 && UnsafeUtil.getByte(tempPos++) < 0
3593 && UnsafeUtil.getByte(tempPos++) < 0
3594 && UnsafeUtil.getByte(tempPos++) < 0) {
3601 return (
int) readRawVarint64SlowPath();
3616 if ((
y = UnsafeUtil.getByte(tempPos++)) >= 0) {
3621 }
else if ((
y ^= (UnsafeUtil.getByte(tempPos++) << 7)) < 0) {
3623 }
else if ((
y ^= (UnsafeUtil.getByte(tempPos++) << 14)) >= 0) {
3624 x =
y ^ ((~0 << 7) ^ (~0 << 14));
3625 }
else if ((
y ^= (UnsafeUtil.getByte(tempPos++) << 21)) < 0) {
3626 x =
y ^ ((~0 << 7) ^ (~0 << 14) ^ (~0 << 21));
3627 }
else if ((
x =
y ^ ((
long) UnsafeUtil.getByte(tempPos++) << 28)) >= 0L) {
3628 x ^= (~0L << 7) ^ (~0L << 14) ^ (~0L << 21) ^ (~0L << 28);
3629 }
else if ((
x ^= ((
long) UnsafeUtil.getByte(tempPos++) << 35)) < 0L) {
3630 x ^= (~0L << 7) ^ (~0L << 14) ^ (~0L << 21) ^ (~0L << 28) ^ (~0L << 35);
3631 }
else if ((
x ^= ((
long) UnsafeUtil.getByte(tempPos++) << 42)) >= 0L) {
3632 x ^= (~0L << 7) ^ (~0L << 14) ^ (~0L << 21) ^ (~0L << 28) ^ (~0L << 35) ^ (~0L << 42);
3633 }
else if ((
x ^= ((
long) UnsafeUtil.getByte(tempPos++) << 49)) < 0L) {
3643 x ^= ((
long) UnsafeUtil.getByte(tempPos++) << 56);
3654 if (UnsafeUtil.getByte(tempPos++) < 0L) {
3662 return readRawVarint64SlowPath();
3666 long readRawVarint64SlowPath() throws IOException {
3668 for (
int shift = 0; shift < 64; shift += 7) {
3670 result |= (
long) (
b & 0x7F) << shift;
3671 if ((
b & 0x80) == 0) {
3675 throw InvalidProtocolBufferException.malformedVarint();
3683 return (((UnsafeUtil.getByte(tempPos) & 0xff))
3684 | ((UnsafeUtil.getByte(tempPos + 1) & 0xff) << 8)
3685 | ((UnsafeUtil.getByte(tempPos + 2) & 0xff) << 16)
3686 | ((UnsafeUtil.getByte(tempPos + 3) & 0xff) << 24));
3699 return (((UnsafeUtil.getByte(tempPos) & 0xffL))
3700 | ((UnsafeUtil.getByte(tempPos + 1) & 0xffL) << 8)
3701 | ((UnsafeUtil.getByte(tempPos + 2) & 0xffL) << 16)
3702 | ((UnsafeUtil.getByte(tempPos + 3) & 0xffL) << 24)
3703 | ((UnsafeUtil.getByte(tempPos + 4) & 0xffL) << 32)
3704 | ((UnsafeUtil.getByte(tempPos + 5) & 0xffL) << 40)
3705 | ((UnsafeUtil.getByte(tempPos + 6) & 0xffL) << 48)
3706 | ((UnsafeUtil.getByte(tempPos + 7) & 0xffL) << 56));
3720 this.enableAliasing =
enabled;
3730 if (byteLimit < 0) {
3735 if (byteLimit > oldLimit) {
3807 return EMPTY_BYTE_ARRAY;
3880 for (
int i = 0;
i < MAX_VARINT_SIZE;
i++) {
3914 }
catch (IllegalArgumentException e) {