mirror of
https://github.com/esphome/esphome.git
synced 2026-09-19 02:58:38 +00:00
[api] Move zero-check into encode_small_varint to simplify call sites
This commit is contained in:
@@ -1345,11 +1345,7 @@ class EnumType(TypeInfo):
|
||||
if max_val is not None and max_val < 128 and not self.force:
|
||||
tag = self.calculate_tag()
|
||||
if tag < 128:
|
||||
return (
|
||||
f"if (this->{self.field_name}) {{\n"
|
||||
f" buffer.encode_small_varint({tag}, static_cast<uint8_t>(this->{self.field_name}));\n"
|
||||
f"}}"
|
||||
)
|
||||
return f"buffer.encode_small_varint({tag}, static_cast<uint8_t>(this->{self.field_name}));"
|
||||
if self.force:
|
||||
return f"buffer.{self.encode_func}({self.number}, {value_expr}, true);"
|
||||
return f"buffer.{self.encode_func}({self.number}, {value_expr});"
|
||||
|
||||
Reference in New Issue
Block a user