mirror of
https://github.com/esphome/esphome.git
synced 2025-07-30 15:16:37 +00:00
dry
This commit is contained in:
parent
a82b5fa87a
commit
5ebce4a901
@ -513,14 +513,9 @@ class ProtoSize {
|
|||||||
* @brief Calculates and adds the size of an int32 field to the total message size (force version)
|
* @brief Calculates and adds the size of an int32 field to the total message size (force version)
|
||||||
*/
|
*/
|
||||||
inline void add_int32_force(uint32_t field_id_size, int32_t value) {
|
inline void add_int32_force(uint32_t field_id_size, int32_t value) {
|
||||||
// Always calculate size when force is true
|
// Always calculate size when forced
|
||||||
if (value < 0) {
|
// Negative values are encoded as 10-byte varints in protobuf
|
||||||
// Negative values are encoded as 10-byte varints in protobuf
|
total_size_ += field_id_size + (value < 0 ? 10 : varint(static_cast<uint32_t>(value)));
|
||||||
total_size_ += field_id_size + 10;
|
|
||||||
} else {
|
|
||||||
// For non-negative values, use the standard varint size
|
|
||||||
total_size_ += field_id_size + varint(static_cast<uint32_t>(value));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user