mirror of
https://github.com/esphome/esphome.git
synced 2025-07-29 22:56:37 +00:00
cleanup
This commit is contained in:
parent
767ec53cfa
commit
4c62f43dcd
@ -981,19 +981,10 @@ class FixedArrayRepeatedType(TypeInfo):
|
|||||||
+ self._ti.get_size_calculation(f"{name}[1]", True)
|
+ self._ti.get_size_calculation(f"{name}[1]", True)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check if this is a fixed-size type by seeing if it has a fixed byte count
|
# Use loops for larger arrays
|
||||||
num_bytes = self._ti.get_fixed_size_bytes()
|
o = f"for (const auto &it : {name}) {{\n"
|
||||||
if num_bytes is not None:
|
o += f" {self._ti.get_size_calculation('it', True)}\n"
|
||||||
# Fixed types have constant size per element, so we can multiply
|
o += "}"
|
||||||
field_id_size = self.calculate_field_id_size()
|
|
||||||
# Pre-calculate the total bytes per element
|
|
||||||
bytes_per_element = field_id_size + num_bytes
|
|
||||||
o = f"total_size += {self.array_size} * {bytes_per_element};"
|
|
||||||
else:
|
|
||||||
# Other types need the actual value
|
|
||||||
o = f"for (const auto &it : {name}) {{\n"
|
|
||||||
o += f" {self._ti.get_size_calculation('it', True)}\n"
|
|
||||||
o += "}"
|
|
||||||
return o
|
return o
|
||||||
|
|
||||||
def get_estimated_size(self) -> int:
|
def get_estimated_size(self) -> int:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user