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

View File

@ -537,13 +537,10 @@ class ProtoSize {
* @brief Calculates and adds the size of a uint32 field to the total message size
*/
inline void add_uint32(uint32_t field_id_size, uint32_t value) {
// Skip calculation if value is zero
if (value == 0) {
return; // No need to update total_size_
}
// Delegate to repeated version
if (value != 0) {
add_uint32_repeated(field_id_size, value);
}
}
/**
* @brief Calculates and adds the size of a uint32 field to the total message size (repeated field version)
@ -617,13 +614,10 @@ class ProtoSize {
* Sint32 fields use ZigZag encoding, which is more efficient for negative values.
*/
inline void add_sint32(uint32_t field_id_size, int32_t value) {
// Skip calculation if value is zero
if (value == 0) {
return; // No need to update total_size_
}
// Delegate to repeated version
if (value != 0) {
add_sint32_repeated(field_id_size, value);
}
}
/**
* @brief Calculates and adds the size of a sint32 field to the total message size (repeated field version)
@ -641,13 +635,10 @@ class ProtoSize {
* @brief Calculates and adds the size of an int64 field to the total message size
*/
inline void add_int64(uint32_t field_id_size, int64_t value) {
// Skip calculation if value is zero
if (value == 0) {
return; // No need to update total_size_
}
// Delegate to repeated version
if (value != 0) {
add_int64_repeated(field_id_size, value);
}
}
/**
* @brief Calculates and adds the size of an int64 field to the total message size (repeated field version)
@ -661,13 +652,10 @@ class ProtoSize {
* @brief Calculates and adds the size of a uint64 field to the total message size
*/
inline void add_uint64(uint32_t field_id_size, uint64_t value) {
// Skip calculation if value is zero
if (value == 0) {
return; // No need to update total_size_
}
// Delegate to repeated version
if (value != 0) {
add_uint64_repeated(field_id_size, value);
}
}
/**
* @brief Calculates and adds the size of a uint64 field to the total message size (repeated field version)
@ -684,13 +672,10 @@ class ProtoSize {
* @brief Calculates and adds the size of a length-delimited field (string/bytes) to the total message size
*/
inline void add_length(uint32_t field_id_size, size_t len) {
// Skip calculation if length is zero
if (len == 0) {
return; // No need to update total_size_
}
// Delegate to repeated version
if (len != 0) {
add_length_repeated(field_id_size, len);
}
}
/**
* @brief Calculates and adds the size of a length-delimited field (string/bytes) to the total message size (repeated