mirror of
https://github.com/esphome/esphome.git
synced 2026-09-16 01:28:39 +00:00
[api] Reuse total_calculated_size in encode_to_buffer return and resize
This commit is contained in:
@@ -2033,8 +2033,7 @@ uint16_t APIConnection::encode_to_buffer(uint32_t calculated_size, MessageEncode
|
||||
// Batch message second or later
|
||||
// Reserve for full message, resize to include footer gap + header padding + payload
|
||||
size_t current_size = shared_buf.size();
|
||||
shared_buf.reserve_and_resize(current_size + total_calculated_size,
|
||||
current_size + footer_size + header_padding + calculated_size);
|
||||
shared_buf.resize(current_size + total_calculated_size);
|
||||
write_start = shared_buf.size() - calculated_size;
|
||||
}
|
||||
|
||||
@@ -2042,7 +2041,7 @@ uint16_t APIConnection::encode_to_buffer(uint32_t calculated_size, MessageEncode
|
||||
encode_fn(msg, buffer);
|
||||
|
||||
// Return total size (header + payload + footer)
|
||||
return static_cast<uint16_t>(header_padding + calculated_size + footer_size);
|
||||
return static_cast<uint16_t>(total_calculated_size);
|
||||
}
|
||||
bool APIConnection::send_buffer(ProtoWriteBuffer buffer, uint8_t message_type) {
|
||||
const bool is_log_message = (message_type == SubscribeLogsResponse::MESSAGE_TYPE);
|
||||
|
||||
Reference in New Issue
Block a user