mirror of
https://github.com/esphome/esphome.git
synced 2025-08-03 00:47:47 +00:00
preen
This commit is contained in:
parent
c2657c1896
commit
eb7f982b5b
@ -351,16 +351,15 @@ void ProtoMessage::decode(const uint8_t *buffer, size_t length) {
|
||||
|
||||
// Try regular fields first using binary search
|
||||
if (const FieldMeta *field = find_field_binary(fields, field_count, field_id)) {
|
||||
void *field_addr = base + field->get_offset();
|
||||
decoded = decode_varint_field(field->get_type(), field_addr, value);
|
||||
decoded = decode_varint_field(field->get_type(), base + field->get_offset(), value);
|
||||
}
|
||||
|
||||
// If not found, try repeated fields (linear search - usually only 1-2 fields)
|
||||
if (!decoded) {
|
||||
for (uint8_t j = 0; j < repeated_count; j++) {
|
||||
if (repeated_fields[j].field_num == field_id) {
|
||||
void *field_addr = base + repeated_fields[j].get_offset();
|
||||
decoded = decode_repeated_varint_field(repeated_fields[j].get_type(), field_addr, value);
|
||||
decoded = decode_repeated_varint_field(repeated_fields[j].get_type(),
|
||||
base + repeated_fields[j].get_offset(), value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -388,17 +387,17 @@ void ProtoMessage::decode(const uint8_t *buffer, size_t length) {
|
||||
|
||||
// Try regular fields first using binary search
|
||||
if (const FieldMeta *field = find_field_binary(fields, field_count, field_id)) {
|
||||
void *field_addr = base + field->get_offset();
|
||||
decoded = decode_length_field(field->get_type(), field_addr, value, field->get_message_type_id());
|
||||
decoded =
|
||||
decode_length_field(field->get_type(), base + field->get_offset(), value, field->get_message_type_id());
|
||||
}
|
||||
|
||||
// If not found, try repeated fields (linear search - usually only 1-2 fields)
|
||||
if (!decoded) {
|
||||
for (uint8_t j = 0; j < repeated_count; j++) {
|
||||
if (repeated_fields[j].field_num == field_id) {
|
||||
void *field_addr = base + repeated_fields[j].get_offset();
|
||||
decoded = decode_repeated_length_field(repeated_fields[j].get_type(), field_addr, value,
|
||||
repeated_fields[j].get_message_type_id());
|
||||
decoded =
|
||||
decode_repeated_length_field(repeated_fields[j].get_type(), base + repeated_fields[j].get_offset(),
|
||||
value, repeated_fields[j].get_message_type_id());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -423,16 +422,15 @@ void ProtoMessage::decode(const uint8_t *buffer, size_t length) {
|
||||
|
||||
// Try regular fields first using binary search
|
||||
if (const FieldMeta *field = find_field_binary(fields, field_count, field_id)) {
|
||||
void *field_addr = base + field->get_offset();
|
||||
decoded = decode_32bit_field(field->get_type(), field_addr, value);
|
||||
decoded = decode_32bit_field(field->get_type(), base + field->get_offset(), value);
|
||||
}
|
||||
|
||||
// If not found, try repeated fields (linear search - usually only 1-2 fields)
|
||||
if (!decoded) {
|
||||
for (uint8_t j = 0; j < repeated_count; j++) {
|
||||
if (repeated_fields[j].field_num == field_id) {
|
||||
void *field_addr = base + repeated_fields[j].get_offset();
|
||||
decoded = decode_repeated_32bit_field(repeated_fields[j].get_type(), field_addr, value);
|
||||
decoded = decode_repeated_32bit_field(repeated_fields[j].get_type(),
|
||||
base + repeated_fields[j].get_offset(), value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user