This commit is contained in:
J. Nick Koston 2025-07-25 23:08:22 -10:00
parent 0155769ffe
commit 5feb891e97
No known key found for this signature in database
2 changed files with 5 additions and 1 deletions

View File

@ -849,7 +849,7 @@ void HomeassistantServiceMap::encode(ProtoWriteBuffer buffer) const {
}
void HomeassistantServiceMap::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->key_ref_.size());
ProtoSize::add_string_field(total_size, 1, this->value);
ProtoSize::add_string_field(total_size, 1, this->value.size());
}
void HomeassistantServiceResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_string(1, this->service_ref_);

View File

@ -654,6 +654,10 @@ class StringType(TypeInfo):
# For SOURCE_CLIENT only messages or no_zero_copy, use the string field directly
if not self._needs_encode or no_zero_copy:
# For no_zero_copy, we need to use .size() on the string
if no_zero_copy and name != "it":
field_id_size = self.calculate_field_id_size()
return f"ProtoSize::add_string_field(total_size, {field_id_size}, this->{self.field_name}.size());"
return self._get_simple_size_calculation(name, force, "add_string_field")
# Check if this is being called from a repeated field context