1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-26 23:22:21 +01:00

Implement zero-copy for strings in base API calls (#10851)

This commit is contained in:
J. Nick Koston
2025-09-23 16:15:28 -05:00
committed by GitHub
parent cd7922faaf
commit d0d7abb542
8 changed files with 62 additions and 26 deletions

View File

@@ -373,6 +373,14 @@ def create_field_type_info(
# Traditional fixed array approach with copy
return FixedArrayBytesType(field, fixed_size)
# Check for pointer_to_buffer option on string fields
if field.type == 9:
has_pointer_to_buffer = get_field_opt(field, pb.pointer_to_buffer, False)
if has_pointer_to_buffer:
# Zero-copy pointer approach for strings
return PointerToBytesBufferType(field, None)
# Special handling for bytes fields
if field.type == 12:
return BytesType(field, needs_decode, needs_encode)