Files
esphome/script
J. Nick Koston da926d904e [api] Precompute tag bytes for forced varint and length-delimited fields
Extend the precomputed-tag approach from fixed32 key fields to all forced
fields with single-byte tags (field IDs 1-15). The code generator now
emits write_raw_byte(tag) followed by the raw encode primitive instead
of calling the full encode_* method.

For varint types (uint32, uint64, sint32, sint64, int64, bool, enum),
this eliminates the zero-check branch and encode_field_raw indirection.
For length-delimited types (bytes, string), it additionally skips the
encode_string wrapper.

Benchmarked on real hardware with BluetoothLERawAdvertisementsResponse
(12 advertisements per message, 10000 iterations):

ESP32 (Xtensa dual-core 240MHz):
  encode: 38498 -> 30460 ns/op (-20.9%)
  calc+encode: 48479 -> 40458 ns/op (-16.6%)

ESP32-C3 (RISC-V single-core 160MHz):
  encode: 54199 -> 40342 ns/op (-25.6%)
  calc+encode: 57800 -> 51365 ns/op (-11.1%)
2026-03-21 11:48:28 -10:00
..
2023-11-25 10:18:36 +11:00