This commit is contained in:
J. Nick Koston 2025-07-26 14:52:15 -10:00
parent d98a3fca96
commit 2e16b3ea31
No known key found for this signature in database

View File

@ -541,9 +541,8 @@ class ProtoSize {
if (value == 0) { if (value == 0) {
return; // No need to update total_size_ return; // No need to update total_size_
} }
// Delegate to repeated version
// Calculate and directly add to total_size add_uint32_repeated(field_id_size, value);
total_size_ += field_id_size + varint(value);
} }
/** /**
@ -622,10 +621,8 @@ class ProtoSize {
if (value == 0) { if (value == 0) {
return; // No need to update total_size_ return; // No need to update total_size_
} }
// Delegate to repeated version
// ZigZag encoding for sint32: (n << 1) ^ (n >> 31) add_sint32_repeated(field_id_size, value);
uint32_t zigzag = (static_cast<uint32_t>(value) << 1) ^ (static_cast<uint32_t>(value >> 31));
total_size_ += field_id_size + varint(zigzag);
} }
/** /**
@ -648,9 +645,8 @@ class ProtoSize {
if (value == 0) { if (value == 0) {
return; // No need to update total_size_ return; // No need to update total_size_
} }
// Delegate to repeated version
// Calculate and directly add to total_size add_int64_repeated(field_id_size, value);
total_size_ += field_id_size + varint(value);
} }
/** /**
@ -669,9 +665,8 @@ class ProtoSize {
if (value == 0) { if (value == 0) {
return; // No need to update total_size_ return; // No need to update total_size_
} }
// Delegate to repeated version
// Calculate and directly add to total_size add_uint64_repeated(field_id_size, value);
total_size_ += field_id_size + varint(value);
} }
/** /**
@ -693,9 +688,8 @@ class ProtoSize {
if (len == 0) { if (len == 0) {
return; // No need to update total_size_ return; // No need to update total_size_
} }
// Delegate to repeated version
// Field ID + length varint + data bytes add_length_repeated(field_id_size, len);
total_size_ += field_id_size + varint(static_cast<uint32_t>(len)) + static_cast<uint32_t>(len);
} }
/** /**