J. Nick Koston
fd68e9a827
[api] Rename encode_raw_short_string to encode_short_string
2026-04-03 14:01:14 -10:00
J. Nick Koston
2d13def0ee
[api] Add encode_raw_short_string for forced string fields with max_data_length
...
Replace 3-call sequence (write_raw_byte + write_raw_byte + encode_raw)
with single inlined encode_raw_short_string call for forced string
fields with max_data_length < 128. The compiler can hoist the pos
pointer across all three writes in one function boundary.
2026-04-03 14:00:01 -10:00
J. Nick Koston
675400cc31
[api] Use .empty() for string zero check in single-byte varint size
2026-04-03 13:51:25 -10:00
J. Nick Koston
e174e579ed
[api] Add max_data_length proto option and optimize entity name/object_id
...
Add max_data_length field option for string/bytes fields. When
max_data_length < 128, the codegen emits constant-size length varint
calculations and direct byte writes.
Annotate all entity name and object_id fields with
(max_data_length) = 120 and (force) = true across all 25
ListEntities*Response messages (50 fields).
Generated code changes:
- calculate_size: `calc_length(1, size)` -> `2 + size` (constant)
- encode: `encode_string(N, ref)` -> `write_raw_byte(tag) + write_raw_byte(len) + encode_raw(data, len)`
Eliminates 2 function calls per field per entity list response,
removes zero-check branches, and removes varint size computation.
2026-04-03 13:33:51 -10:00
J. Nick Koston
9ece286a26
[api] Simplify _get_single_byte_varint_size
2026-04-03 12:32:32 -10:00
J. Nick Koston
fa80caf0ff
[api] Fall back to RAW_ENCODE_MAP when SMALL_MAP has no entry
2026-04-03 12:31:44 -10:00
J. Nick Koston
f3238a857e
[api] Select encode map before lookup
2026-04-03 12:31:01 -10:00
J. Nick Koston
02b424388e
[api] Use RAW_ENCODE_SMALL_MAP for max_value encode optimization
...
Replace inline encode_func check with a lookup table, matching the
existing RAW_ENCODE_MAP pattern.
2026-04-03 12:28:51 -10:00
J. Nick Koston
363d811cc1
[api] Use _get_simple_size_calculation for FixedArrayBytesType fallback
...
Replace inline calc_length/calc_length_force formatting with the
existing helper method.
2026-04-03 12:27:55 -10:00
J. Nick Koston
1e68a90ac9
[api] Extract _get_single_byte_varint_size helper in codegen
...
Refactor the constant-size varint pattern into a reusable helper
method on the TypeInfo base class, used by both UInt32Type (max_value)
and FixedArrayBytesType (fixed_array_size < 128).
2026-04-03 12:26:51 -10:00
J. Nick Koston
e35aa729f3
[api] Add max_value proto option for constant-size varint codegen
...
Add a max_value field option to api_options.proto that tells the code
generator the maximum value a field can have. When max_value < 128,
the generated calculate_size() uses constant arithmetic instead of
calling varint size functions, and encode() uses direct byte writes
instead of varint encoding.
Also optimize FixedArrayBytesType: when fixed_array_size < 128, the
length varint is always 1 byte, so calculate_size() uses constant
arithmetic and encode() uses write_raw_byte for the length.
Applied to BluetoothLERawAdvertisement.address_type (max_value=4).
Measured on ESP32 (upstairsdesk89proxy):
- BluetoothLERawAdvertisement::calculate_size: 88 → 71 bytes (-19%)
- BluetoothLERawAdvertisement::encode: 199 → 179 bytes (-10%)
- Total BLE proxy hot path: 1807 → 1770 bytes (-37 bytes)
2026-04-03 12:21:37 -10:00
J. Nick Koston
793813790a
[api] Precompute tag bytes for forced varint and length-delimited fields ( #15067 )
2026-03-24 01:52:39 +00:00
J. Nick Koston
382de7ca90
[api] Store dump strings in PROGMEM to save RAM on ESP8266 ( #14982 )
2026-03-23 13:40:53 -10:00
J. Nick Koston
36d2e58b11
[api] Make ProtoDecodableMessage::decode() non-virtual ( #15076 )
2026-03-23 08:23:08 -10:00
J. Nick Koston
f4097d5a95
[api] Devirtualize API command dispatch ( #15044 )
2026-03-23 19:57:40 +13:00
J. Nick Koston
fbe3e7d99c
[api] Emit raw tag+value writes for forced fixed32 key fields ( #15051 )
2026-03-22 15:28:46 -10:00
J. Nick Koston
05d285ba86
[api] Fix heap-buffer-overflow in protobuf message dump for StringRef ( #14721 )
2026-03-12 07:16:53 -10:00
J. Nick Koston
6e468936ec
[api] Inline ProtoVarInt::parse fast path and return consumed in struct ( #14638 )
...
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com >
2026-03-10 09:10:55 -10:00
J. Nick Koston
be6c3c52ac
[api] Add force proto field option to skip zero checks on hot path ( #14610 )
...
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com >
2026-03-07 18:59:13 -10:00
J. Nick Koston
77f2c371b2
[api] Single-pass protobuf encode for BLE proxy advertisements ( #14575 )
2026-03-07 07:26:34 -10:00
J. Nick Koston
42dbb51022
[api] Devirtualize protobuf encode/calculate_size ( #14449 )
...
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com >
2026-03-06 19:03:54 +00:00
J. Nick Koston
f68a3ed15d
[api] Remove virtual destructor from ProtoMessage ( #14393 )
2026-03-01 18:09:00 -10:00
J. Nick Koston
8bb577de64
[api] Split ProtoVarInt::parse into 32-bit and 64-bit phases ( #14039 )
2026-02-25 12:23:13 -06:00
J. Nick Koston
f77da803c9
[api] Write protobuf encode output to pre-sized buffer directly ( #14018 )
2026-02-20 21:39:18 -06:00
J. Nick Koston
6c6da8a3cd
[api] Skip class generation for empty SOURCE_CLIENT protobuf messages ( #13880 )
2026-02-09 18:45:24 +00:00
J. Nick Koston
c658d7b57f
[api] Merge auth check into base read_message, eliminate APIServerConnection ( #13873 )
2026-02-09 12:02:02 -06:00
J. Nick Koston
3cde3daceb
[api] Collapse APIServerConnection intermediary layer ( #13872 )
2026-02-09 08:45:33 -06:00
J. Nick Koston
140ec0639c
[api] Elide empty message construction in protobuf dispatch ( #13871 )
2026-02-09 03:24:45 -06:00
J. Nick Koston
55ef8393af
[api] Remove is_single parameter and fix batch buffer preparation ( #13773 )
...
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com >
2026-02-05 15:19:03 +01:00
dependabot[bot]
4d05cd3059
Bump ruff from 0.14.14 to 0.15.0 ( #13752 )
...
Signed-off-by: dependabot[bot] <support@github.com >
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@home-assistant.io >
2026-02-04 09:24:05 +00:00
J. Nick Koston
8d0ce49eb4
[api] Eliminate intermediate buffers in protobuf dump helpers ( #13742 )
...
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com >
2026-02-03 16:34:15 +01:00
J. Nick Koston
7fed9144a6
[api] Use stack buffer for VERY_VERBOSE proto message dumps ( #13176 )
2026-01-13 08:04:48 -10:00
J. Nick Koston
7ea6bcef88
[api] Use stack buffer for bytes field dumping in proto message logs ( #13162 )
2026-01-12 07:37:58 -10:00
J. Nick Koston
912f94d1e8
[api] Use StringRef for HomeassistantServiceMap.value to eliminate heap allocations ( #13154 )
...
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com >
2026-01-11 17:54:06 -10:00
Keith Burzinski
f2eb61a767
[api] Proto code generator changes for #12985 ( #13100 )
...
Co-authored-by: J. Nick Koston <nick@koston.org >
2026-01-10 15:43:27 -10:00
J. Nick Koston
546cdbde0d
[api] Simplify string handling by removing bifurcated client/server storage ( #12822 )
2026-01-07 08:23:28 -10:00
J. Nick Koston
2a5be725c8
[api] Enable zero-copy bytes SOURCE_BOTH messages ( #12816 )
2026-01-02 19:50:30 -10:00
J. Nick Koston
e7001c5eea
[api] Auto-generate zero-copy pointer access for incoming API bytes fields ( #12654 )
2026-01-02 14:05:37 -10:00
J. Nick Koston
6d4f4d8d23
[api] Auto-generate StringRef for incoming API string fields ( #12648 )
2026-01-02 08:17:05 -10:00
J. Nick Koston
b47b7d43fd
[api] Remove unused force parameter from encode_message ( #12551 )
2025-12-18 09:06:16 -07:00
J. Nick Koston
fb82362e9c
[api] Eliminate rx_buf heap churn and release buffers after initial sync ( #12133 )
2025-11-28 12:13:29 -06:00
Jonathan Swoboda
61cef0a75c
[api] Fix format warnings in dump ( #11999 )
2025-11-19 12:58:47 -05:00
J. Nick Koston
42833c85f5
[climate] Replace std::vector<std::string> with const char* for custom fan modes and presets ( #11621 )
2025-11-02 23:16:39 -06:00
J. Nick Koston
f3634edc22
[select] Store options in flash to reduce RAM usage ( #11514 )
2025-10-29 15:28:16 +13:00
J. Nick Koston
fdecda3d65
[light] Use bitmask instead of std::set for color modes ( #11348 )
2025-10-20 07:48:14 +13:00
J. Nick Koston
6943b1d985
[api] Use FixedVector for ExecuteServiceRequest/Argument arrays to eliminate reallocations ( #11270 )
2025-10-16 16:22:08 +13:00
J. Nick Koston
8a15c18066
[bluetooth_proxy] Use FixedVector for GATT characteristics and descriptors ( #11214 )
...
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com >
2025-10-14 16:05:13 +13:00
J. Nick Koston
adfacdf1b7
[api] Consolidate authentication checks to reduce function call overhead ( #10852 )
2025-09-23 19:43:55 -05:00
J. Nick Koston
d0d7abb542
Implement zero-copy for strings in base API calls ( #10851 )
2025-09-23 16:15:28 -05:00
J. Nick Koston
2f8a4d0caa
[api] Implement zero-copy API for bluetooth_proxy writes ( #10840 )
2025-09-23 13:48:57 -05:00