diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index 1c7012370b..edd6dfc6a9 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -23,7 +23,6 @@ bool HelloRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { bool HelloRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 1: { - // Use raw data directly via StringRef to avoid allocation this->client_info = StringRef(reinterpret_cast(value.data()), value.size()); break; } @@ -48,7 +47,6 @@ void HelloResponse::calculate_size(ProtoSize &size) const { bool AuthenticationRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 1: { - // Use raw data directly via StringRef to avoid allocation this->password = StringRef(reinterpret_cast(value.data()), value.size()); break; } @@ -446,7 +444,6 @@ bool FanCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { bool FanCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 13: { - // Use raw data directly via StringRef to avoid allocation this->preset_mode = StringRef(reinterpret_cast(value.data()), value.size()); break; } @@ -612,7 +609,6 @@ bool LightCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { bool LightCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 19: { - // Use raw data directly via StringRef to avoid allocation this->effect = StringRef(reinterpret_cast(value.data()), value.size()); break; } @@ -855,7 +851,6 @@ void SubscribeLogsResponse::calculate_size(ProtoSize &size) const { bool NoiseEncryptionSetKeyRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 1: { - // Use raw data directly to avoid allocation this->key = value.data(); this->key_len = value.size(); break; @@ -933,13 +928,11 @@ bool HomeassistantActionResponse::decode_varint(uint32_t field_id, ProtoVarInt v bool HomeassistantActionResponse::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 3: { - // Use raw data directly via StringRef to avoid allocation this->error_message = StringRef(reinterpret_cast(value.data()), value.size()); break; } #ifdef USE_API_HOMEASSISTANT_ACTION_RESPONSES_JSON case 4: { - // Use raw data directly to avoid allocation this->response_data = value.data(); this->response_data_len = value.size(); break; @@ -965,17 +958,14 @@ void SubscribeHomeAssistantStateResponse::calculate_size(ProtoSize &size) const bool HomeAssistantStateResponse::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 1: { - // Use raw data directly via StringRef to avoid allocation this->entity_id = StringRef(reinterpret_cast(value.data()), value.size()); break; } case 2: { - // Use raw data directly via StringRef to avoid allocation this->state = StringRef(reinterpret_cast(value.data()), value.size()); break; } case 3: { - // Use raw data directly via StringRef to avoid allocation this->attribute = StringRef(reinterpret_cast(value.data()), value.size()); break; } @@ -988,7 +978,6 @@ bool HomeAssistantStateResponse::decode_length(uint32_t field_id, ProtoLengthDel bool GetTimeResponse::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 2: { - // Use raw data directly via StringRef to avoid allocation this->timezone = StringRef(reinterpret_cast(value.data()), value.size()); break; } @@ -1055,7 +1044,6 @@ bool ExecuteServiceArgument::decode_varint(uint32_t field_id, ProtoVarInt value) bool ExecuteServiceArgument::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 4: { - // Use raw data directly via StringRef to avoid allocation this->string_ = StringRef(reinterpret_cast(value.data()), value.size()); break; } @@ -1404,12 +1392,10 @@ bool ClimateCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) bool ClimateCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 17: { - // Use raw data directly via StringRef to avoid allocation this->custom_fan_mode = StringRef(reinterpret_cast(value.data()), value.size()); break; } case 21: { - // Use raw data directly via StringRef to avoid allocation this->custom_preset = StringRef(reinterpret_cast(value.data()), value.size()); break; } @@ -1696,7 +1682,6 @@ bool SelectCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { bool SelectCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 2: { - // Use raw data directly via StringRef to avoid allocation this->state = StringRef(reinterpret_cast(value.data()), value.size()); break; } @@ -1802,7 +1787,6 @@ bool SirenCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { bool SirenCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 5: { - // Use raw data directly via StringRef to avoid allocation this->tone = StringRef(reinterpret_cast(value.data()), value.size()); break; } @@ -1895,7 +1879,6 @@ bool LockCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { bool LockCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 4: { - // Use raw data directly via StringRef to avoid allocation this->code = StringRef(reinterpret_cast(value.data()), value.size()); break; } @@ -2067,7 +2050,6 @@ bool MediaPlayerCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt val bool MediaPlayerCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 7: { - // Use raw data directly via StringRef to avoid allocation this->media_url = StringRef(reinterpret_cast(value.data()), value.size()); break; } @@ -2278,7 +2260,6 @@ bool BluetoothGATTWriteRequest::decode_varint(uint32_t field_id, ProtoVarInt val bool BluetoothGATTWriteRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 4: { - // Use raw data directly to avoid allocation this->data = value.data(); this->data_len = value.size(); break; @@ -2317,7 +2298,6 @@ bool BluetoothGATTWriteDescriptorRequest::decode_varint(uint32_t field_id, Proto bool BluetoothGATTWriteDescriptorRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 3: { - // Use raw data directly to avoid allocation this->data = value.data(); this->data_len = value.size(); break; @@ -2502,12 +2482,10 @@ bool VoiceAssistantResponse::decode_varint(uint32_t field_id, ProtoVarInt value) bool VoiceAssistantEventData::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 1: { - // Use raw data directly via StringRef to avoid allocation this->name = StringRef(reinterpret_cast(value.data()), value.size()); break; } case 2: { - // Use raw data directly via StringRef to avoid allocation this->value = StringRef(reinterpret_cast(value.data()), value.size()); break; } @@ -2587,12 +2565,10 @@ bool VoiceAssistantTimerEventResponse::decode_varint(uint32_t field_id, ProtoVar bool VoiceAssistantTimerEventResponse::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 2: { - // Use raw data directly via StringRef to avoid allocation this->timer_id = StringRef(reinterpret_cast(value.data()), value.size()); break; } case 3: { - // Use raw data directly via StringRef to avoid allocation this->name = StringRef(reinterpret_cast(value.data()), value.size()); break; } @@ -2614,17 +2590,14 @@ bool VoiceAssistantAnnounceRequest::decode_varint(uint32_t field_id, ProtoVarInt bool VoiceAssistantAnnounceRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 1: { - // Use raw data directly via StringRef to avoid allocation this->media_id = StringRef(reinterpret_cast(value.data()), value.size()); break; } case 2: { - // Use raw data directly via StringRef to avoid allocation this->text = StringRef(reinterpret_cast(value.data()), value.size()); break; } case 3: { - // Use raw data directly via StringRef to avoid allocation this->preannounce_media_id = StringRef(reinterpret_cast(value.data()), value.size()); break; } @@ -2664,12 +2637,10 @@ bool VoiceAssistantExternalWakeWord::decode_varint(uint32_t field_id, ProtoVarIn bool VoiceAssistantExternalWakeWord::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 1: { - // Use raw data directly via StringRef to avoid allocation this->id = StringRef(reinterpret_cast(value.data()), value.size()); break; } case 2: { - // Use raw data directly via StringRef to avoid allocation this->wake_word = StringRef(reinterpret_cast(value.data()), value.size()); break; } @@ -2677,17 +2648,14 @@ bool VoiceAssistantExternalWakeWord::decode_length(uint32_t field_id, ProtoLengt this->trained_languages.push_back(value.as_string()); break; case 4: { - // Use raw data directly via StringRef to avoid allocation this->model_type = StringRef(reinterpret_cast(value.data()), value.size()); break; } case 6: { - // Use raw data directly via StringRef to avoid allocation this->model_hash = StringRef(reinterpret_cast(value.data()), value.size()); break; } case 7: { - // Use raw data directly via StringRef to avoid allocation this->url = StringRef(reinterpret_cast(value.data()), value.size()); break; } @@ -2801,7 +2769,6 @@ bool AlarmControlPanelCommandRequest::decode_varint(uint32_t field_id, ProtoVarI bool AlarmControlPanelCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 3: { - // Use raw data directly via StringRef to avoid allocation this->code = StringRef(reinterpret_cast(value.data()), value.size()); break; } @@ -2887,7 +2854,6 @@ bool TextCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { bool TextCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 2: { - // Use raw data directly via StringRef to avoid allocation this->state = StringRef(reinterpret_cast(value.data()), value.size()); break; } @@ -3358,7 +3324,6 @@ bool UpdateCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { bool ZWaveProxyFrame::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 1: { - // Use raw data directly to avoid allocation this->data = value.data(); this->data_len = value.size(); break; @@ -3383,7 +3348,6 @@ bool ZWaveProxyRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { bool ZWaveProxyRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 2: { - // Use raw data directly to avoid allocation this->data = value.data(); this->data_len = value.size(); break; diff --git a/script/api_protobuf/api_protobuf.py b/script/api_protobuf/api_protobuf.py index af7d6af954..f22b248747 100755 --- a/script/api_protobuf/api_protobuf.py +++ b/script/api_protobuf/api_protobuf.py @@ -887,7 +887,6 @@ class PointerToBytesBufferType(PointerToBufferTypeBase): @property def decode_length_content(self) -> str | None: return f"""case {self.number}: {{ - // Use raw data directly to avoid allocation this->{self.field_name} = value.data(); this->{self.field_name}_len = value.size(); break;