1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-04 20:32:21 +01:00

[api] Use static allocation for areas and devices in DeviceInfoResponse (#10038)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
J. Nick Koston
2025-08-03 16:37:47 -10:00
committed by GitHub
parent 6a5eb460ef
commit c0c0a42362
4 changed files with 21 additions and 13 deletions

View File

@@ -115,12 +115,12 @@ void DeviceInfoResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_bool(19, this->api_encryption_supported);
#endif
#ifdef USE_DEVICES
for (auto &it : this->devices) {
for (const auto &it : this->devices) {
buffer.encode_message(20, it, true);
}
#endif
#ifdef USE_AREAS
for (auto &it : this->areas) {
for (const auto &it : this->areas) {
buffer.encode_message(21, it, true);
}
#endif
@@ -167,10 +167,14 @@ void DeviceInfoResponse::calculate_size(ProtoSize &size) const {
size.add_bool(2, this->api_encryption_supported);
#endif
#ifdef USE_DEVICES
size.add_repeated_message(2, this->devices);
for (const auto &it : this->devices) {
size.add_message_object_force(2, it);
}
#endif
#ifdef USE_AREAS
size.add_repeated_message(2, this->areas);
for (const auto &it : this->areas) {
size.add_message_object_force(2, it);
}
#endif
#ifdef USE_AREAS
size.add_message_object(2, this->area);