This commit is contained in:
J. Nick Koston 2025-07-10 15:56:03 -10:00
parent 084ecf93a7
commit c745140835
No known key found for this signature in database

View File

@ -662,14 +662,10 @@ void ProtoMessage::calculate_size(uint32_t &total_size) const {
// For fixed-size types, we can calculate size more efficiently // For fixed-size types, we can calculate size more efficiently
if (type == ProtoFieldType::TYPE_FIXED32 || type == ProtoFieldType::TYPE_SFIXED32 || if (type == ProtoFieldType::TYPE_FIXED32 || type == ProtoFieldType::TYPE_SFIXED32 ||
type == ProtoFieldType::TYPE_FLOAT) { type == ProtoFieldType::TYPE_FLOAT) {
if (count > 0) { total_size += count * (repeated_fields[i].get_precalced_size() + 4);
total_size += count * (repeated_fields[i].get_precalced_size() + 4);
}
} else if (type == ProtoFieldType::TYPE_FIXED64 || type == ProtoFieldType::TYPE_SFIXED64 || } else if (type == ProtoFieldType::TYPE_FIXED64 || type == ProtoFieldType::TYPE_SFIXED64 ||
type == ProtoFieldType::TYPE_DOUBLE) { type == ProtoFieldType::TYPE_DOUBLE) {
if (count > 0) { total_size += count * (repeated_fields[i].get_precalced_size() + 8);
total_size += count * (repeated_fields[i].get_precalced_size() + 8);
}
} else { } else {
// For variable-size types, calculate each element // For variable-size types, calculate each element
for (size_t j = 0; j < count; j++) { for (size_t j = 0; j < count; j++) {