Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static ParseAndDefaultBody generateParseLoop(
while (input.hasRemaining()) {
// Read the "tag" byte which gives us the field number for the next field to read
// and the wire type (way it is encoded on the wire).
final int $prefixtag = input.readVarInt(false);
final int $prefixtag = input.readVarIntNoZZ();

// The field is the top 5 bits of the byte. Read this off
final int $prefixfield = $prefixtag >>> TAG_FIELD_OFFSET;
Expand Down Expand Up @@ -321,7 +321,7 @@ private static void generateFieldCaseStatementPacked(

sbFunc.append("""
// Read the length of packed repeated field data
final int length = input.readVarInt(false);
final int length = input.readVarIntNoZZ();
if (length > $maxSize) {
input.setError(PbjReader.PARSE, "$fieldName size " + length + " is greater than max " + $maxSize);
return $tempFieldName;
Expand Down Expand Up @@ -379,13 +379,13 @@ private static void generateFieldCaseStatement(
if (field.optionalValueType()) {
sbCase.append("""
// Read the message size, it is not needed
final var valueTypeMessageSize = input.readVarInt(false);
final var valueTypeMessageSize = input.readVarIntNoZZ();
final $fieldType value;
if (valueTypeMessageSize > 0) {
final var beforeLimit = input.limit();
input.limit(input.position() + valueTypeMessageSize);
// read inner tag
final int valueFieldTag = input.readVarInt(false);
final int valueFieldTag = input.readVarIntNoZZ();
// assert tag is as expected; skip if a read error is already pending
assert input.error() != 0 || (valueFieldTag >>> TAG_FIELD_OFFSET) == 1;
assert input.error() != 0 || (valueFieldTag & TAG_WIRE_TYPE_MASK) == $valueTypeWireType;
Expand Down Expand Up @@ -424,7 +424,7 @@ private static void generateFieldCaseStatement(
} else if (field.type() == Field.FieldType.MESSAGE) {
// spotless:off
sbCase.append("""
final var messageLength = input.readVarInt(false);
final var messageLength = input.readVarIntNoZZ();
final $fieldType value;
if (messageLength == 0) {
value = $fieldType.DEFAULT;
Expand Down Expand Up @@ -469,7 +469,7 @@ private static void generateFieldCaseStatement(
generateCaseStatements(sbFunc, mapEntryFields, schemaClassName), "map_entry_", schemaClassName);
// spotless:off
sbCase.append("""
final var __map_messageLength = input.readVarInt(false);
final var __map_messageLength = input.readVarIntNoZZ();

$fieldDefs
if (__map_messageLength != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected final void writeImpl(@NonNull $modelClass data, @NonNull final PbjWrit
if (!data.getUnknownFields().isEmpty()) {
data.getUnknownFields().forEach(uf -> {
final int tag = (uf.field() << TAG_FIELD_OFFSET) | uf.wireType().ordinal();
out.writeVarInt(tag, false);
out.writeVarIntNoZZ(tag);
uf.bytes().writeTo(out);
});
}
Expand Down Expand Up @@ -177,7 +177,7 @@ private static String generateFieldWriteLines(
$V v = pbjMap.get(k);
int size = 0;
$fieldSizeOfLines
out.writeVarInt(size, false);
out.writeVarIntNoZZ(size);
$fieldWriteLines
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static int readInt32(final ReadableSequentialData input) {
* @return the read int
*/
public static int readInt32(PbjReader input) {
return input.readVarInt(false);
return input.readVarIntNoZZ();
}

/**
Expand All @@ -109,7 +109,7 @@ public static long readInt64(final ReadableSequentialData input) {
* @return the read long
*/
public static long readInt64(PbjReader input) {
return input.readVarLong(false);
return input.readVarLongNoZZ();
}

/**
Expand All @@ -129,7 +129,7 @@ public static int readUint32(final ReadableSequentialData input) {
* @return the read int
*/
public static int readUint32(PbjReader input) {
return input.readVarInt(false);
return input.readVarIntNoZZ();
}

/**
Expand All @@ -149,7 +149,7 @@ public static long readUint64(final ReadableSequentialData input) {
* @return the read long
*/
public static long readUint64(PbjReader input) {
return input.readVarLong(false);
return input.readVarLongNoZZ();
}

/**
Expand All @@ -174,7 +174,7 @@ public static boolean readBool(final ReadableSequentialData input) throws IOExce
* @return the read boolean
*/
public static boolean readBool(PbjReader input) {
final var i = input.readVarInt(false);
final var i = input.readVarIntNoZZ();
if (i != 1 && i != 0) {
input.setError(PbjReader.DATA_ENCODING);
}
Expand All @@ -198,7 +198,7 @@ public static int readEnum(final ReadableSequentialData input) {
* @return the read enum protoc ordinal
*/
public static int readEnum(PbjReader input) {
return input.readVarInt(false);
return input.readVarIntNoZZ();
}

/**
Expand Down Expand Up @@ -605,7 +605,7 @@ public static Bytes readBytes(final ReadableSequentialData input, final long max
* of InputData
*/
public static Bytes readBytes(final PbjReader input, final long maxSize) {
final int length = input.readVarInt(false);
final int length = input.readVarIntNoZZ();
if (length > maxSize || length < 0) {
input.setError(PbjReader.PARSE);
return Bytes.EMPTY;
Expand Down Expand Up @@ -868,7 +868,7 @@ public static void skipField(final PbjReader input, final ProtoConstants wireTyp
// The value for "zigZag" when calling varint doesn't matter because we are just reading past
// the varint, we don't care how to interpret it (zigzag is only used for interpretation of
// the bytes, not how many of them there are)
case WIRE_TYPE_VARINT_OR_ZIGZAG -> input.readVarLong(false);
case WIRE_TYPE_VARINT_OR_ZIGZAG -> input.readVarLongNoZZ();
case WIRE_TYPE_DELIMITED -> {
final int length = input.readVarIntNoZZ();
if (length < 0) {
Expand Down Expand Up @@ -903,7 +903,7 @@ public static int readNextFieldNumber(final ReadableSequentialData input) {
* @return the read tag
*/
public static int readNextFieldNumber(final PbjReader input) {
final int tag = input.readVarInt(false);
final int tag = input.readVarIntNoZZ();
return tag >> TAG_FIELD_OFFSET;
}
}
Loading
Loading