Skip to content

Commit

Permalink
Fix review comments
Browse files Browse the repository at this point in the history
Signed-off-by: jasperpotts <[email protected]>
  • Loading branch information
jasperpotts committed Jan 9, 2025
1 parent 9869050 commit d9f81b9
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1392,17 +1392,17 @@ public static int sizeOfIntegerList(FieldDefinition field, List<Integer> list) {
final int listSize = list.size();
switch (field.type()) {
case INT32 -> {
for(int i = 0; i < listSize; i++) {
for (int i = 0; i < listSize; i++) {
size += sizeOfVarInt32(list.get(i));
}
}
case UINT32 -> {
for(int i = 0; i < listSize; i++) {
for (int i = 0; i < listSize; i++) {
size += sizeOfUnsignedVarInt32(list.get(i));
}
}
case SINT32 -> {
for(int i = 0; i < listSize; i++) {
for (int i = 0; i < listSize; i++) {
final long val = list.get(i);
size += sizeOfUnsignedVarInt64((val << 1) ^ (val >> 63));
}
Expand Down Expand Up @@ -1523,7 +1523,7 @@ public static int sizeOfEnumList(FieldDefinition field, List<? extends EnumWithP
public static int sizeOfStringList(FieldDefinition field, List<String> list) {
int size = 0;
final int listSize = list.size();
for(int i = 0; i < listSize; i++) {
for (int i = 0; i < listSize; i++) {
size += sizeOfDelimited(field, sizeOfStringNoTag(list.get(i)));
}
return size;
Expand All @@ -1541,7 +1541,7 @@ public static int sizeOfStringList(FieldDefinition field, List<String> list) {
public static <T> int sizeOfMessageList(FieldDefinition field, List<T> list, Codec<T> codec) {
int size = 0;
final int listSize = list.size();
for(int i = 0; i < listSize; i++) {
for (int i = 0; i < listSize; i++) {
size += sizeOfMessage(field, list.get(i), codec);
}
return size;
Expand All @@ -1557,13 +1557,20 @@ public static <T> int sizeOfMessageList(FieldDefinition field, List<T> list, Cod
public static int sizeOfBytesList(FieldDefinition field, List<? extends RandomAccessData> list) {
int size = 0;
final int listSize = list.size();
for(int i = 0; i < listSize; i++) {
for (int i = 0; i < listSize; i++) {
final long valueLength = list.get(i).length();
size += Math.toIntExact(sizeOfTag(field, WIRE_TYPE_DELIMITED) + sizeOfVarInt32(Math.toIntExact(valueLength)) + valueLength);
size += sizeOfDelimited(field, Math.toIntExact(valueLength));
}
return size;
}

/**
* Get number of bytes that would be needed to encode a field of wire type delimited
*
* @param field The field definition of the field to be measured
* @param length The length of the delimited field data in bytes
* @return the number of bytes for encoded value
*/
public static int sizeOfDelimited(final FieldDefinition field, final int length) {
return Math.toIntExact(sizeOfTag(field, WIRE_TYPE_DELIMITED) + sizeOfVarInt32(length) + length);
}
Expand Down

0 comments on commit d9f81b9

Please sign in to comment.