[api] Reuse total_calculated_size in encode_to_buffer return and resize

This commit is contained in:
J. Nick Koston
2026-04-01 11:02:15 -10:00
parent 09648b86f9
commit 69a2609d58
+2 -3
View File
@@ -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);