Commit Graph

22539 Commits

Author SHA1 Message Date
J. Nick Koston
b2b5bf0996 Merge branch 'http_request_reduce_stl_overhead' into integration 2026-02-16 18:54:09 -06:00
J. Nick Koston
aa3ac552c8 [http_request] Restore descriptive variable name in start() 2026-02-16 18:48:32 -06:00
J. Nick Koston
2fa6c15fc1 [http_request] Remove unnecessary lowercase_headers template helper
The template only existed to share a loop between set and vector
iterators. Instead, have the deprecated set overload forward to
the vector overload, and inline the loop there.
2026-02-16 18:38:31 -06:00
J. Nick Koston
7726d0aac9 [http_request] Rename should_collect_header param to lower_header_name
Makes it clear the caller must pass an already-lowercased header name.
2026-02-16 18:37:08 -06:00
J. Nick Koston
f43ef21c69 [http_request] Remove redundant lowercasing from add_collect_header
start() already lowercases all collect_headers via lowercase_headers(),
so pre-lowercasing at insertion time was redundant double work on
every request.
2026-02-16 18:34:41 -06:00
J. Nick Koston
d2037aef8d [http_request] Extract lowercase_headers helper to avoid double-copy
Both start() overloads now use a shared lowercase_headers() template
that does a single pass from any iterator range, avoiding the extra
vector copy that the set overload was doing.
2026-02-16 18:28:04 -06:00
J. Nick Koston
a55abd8e5f [http_request] Deduplicate lowercasing in start() overloads
Have the deprecated std::set overload forward to the vector overload
which already handles lowercasing.
2026-02-16 18:26:12 -06:00
J. Nick Koston
7c36dfa1fc [http_request] Ensure start() vector overload lowercases collect_headers
The vector overload of start() was passing collect_headers directly
to perform() without lowercasing. This meant callers using get()/post()
with mixed-case header names (e.g. {"ETag"}) would fail to match
against the lowercased header names from the HTTP response.
2026-02-16 18:24:41 -06:00
J. Nick Koston
5e7b4c1e6c [http_request] Add comment explaining why start() calls perform() directly
The no-collect-headers start() overload calls perform() directly
instead of the vector start() overload to avoid ambiguity with
the deprecated std::set overload.
2026-02-16 18:17:53 -06:00
J. Nick Koston
3043ba8d89 [http_request] Deprecate std::set overloads of start(), use std::vector for get()/post()
- Change get()/post() collect_headers param from std::set to std::vector
  (initializer list callers like online_image work unchanged)
- Add ESPDEPRECATED on start() std::set overload with clear message
  about the collect_headers parameter
2026-02-16 18:17:11 -06:00
J. Nick Koston
8120bd373c [http_request] Replace std::map/std::set/std::list with std::vector for response headers
Replace heavy STL containers with simple std::vector and linear scan
for response header collection. This eliminates red-black tree (_Rb_tree)
and hash table template instantiations that are unnecessary for the small
number of headers typically collected (1-5 elements).

Changes:
- response_headers_: std::map<string, list<string>> -> std::vector<Header>
- collect_headers_: std::set<string> -> std::vector<string>
- perform() signature: std::set -> std::vector
- Add should_collect_header() inline helper for linear scan
- Lowercase collect_headers at config/insertion time instead of per-request
- IDF UserData now holds references to container's vector instead of
  owning a separate map that gets moved after the request
- Reuse existing Header struct instead of std::pair

Reduces stack usage in perform() and eliminates STL container overhead
on memory-constrained ESP devices.
2026-02-16 18:11:58 -06:00
J. Nick Koston
63bf03c467 Merge branch 'api-proto-write-presized-buffer' into integration 2026-02-16 16:09:01 -06:00
J. Nick Koston
5aef550c71 address copilot revie wcomments 2026-02-16 16:05:54 -06:00
J. Nick Koston
9d387b66db address copilot revie wcomments 2026-02-16 16:03:35 -06:00
J. Nick Koston
61c4288097 [api] Address review: comment noinline, simplify non-debug signature 2026-02-16 15:27:11 -06:00
J. Nick Koston
9710ba3093 Merge remote-tracking branch 'origin/integration' into integration 2026-02-16 15:17:35 -06:00
J. Nick Koston
09f604f2fc Merge branch 'api-proto-write-presized-buffer' into integration
# Conflicts:
#	esphome/components/api/proto.h
2026-02-16 15:17:06 -06:00
J. Nick Koston
f1d51773af Revert "[api] Pass ProtoWriteBuffer by reference in encode()"
This reverts commit 6369f3b279.
2026-02-16 15:12:10 -06:00
J. Nick Koston
6369f3b279 [api] Pass ProtoWriteBuffer by reference in encode()
Pass ProtoWriteBuffer by reference instead of by value in virtual
encode() methods. This avoids copying both buffer_ and pos_ pointers
for every encode call - only a single pointer is passed.

Also simplifies encode_message since child writes directly advance
the shared pos_. Adds debug_check_size_ to verify calculate_size
matches actual encode output.
2026-02-16 15:01:59 -06:00
J. Nick Koston
af4579ca87 [api] Write protobuf encode output to pre-sized buffer directly
ProtoSize::calculate_size() already computes the exact encoded size
before encode() runs and is the boundary validation. The buffer is
pre-sized to match. Since the buffer size is always correct,
push_back() capacity checks on every byte are redundant overhead.

Rename ProtoWriteBuffer to ProtoWritePreSizedBuffer to document the
contract. Write through a raw uint8_t* pointer instead of push_back().
Pre-resize the buffer to include payload space before encoding.

Add ESPHOME_DEBUG_API bounds checks to validate writes stay within the
pre-sized region during development and integration testing.
2026-02-16 14:40:55 -06:00
J. Nick Koston
d0973fd327 Merge branch 'api-proto-write-presized-buffer' into integration 2026-02-16 11:30:09 -06:00
J. Nick Koston
7177add985 [api] Write protobuf encode output to pre-sized buffer directly
ProtoSize::calculate_size() already computes the exact encoded size
before encode() runs and is the boundary validation. The buffer is
pre-sized to match. Since the buffer size is always correct,
push_back() capacity checks on every byte are redundant overhead.

Rename ProtoWriteBuffer to ProtoWritePreSizedBuffer to document the
contract. Write through a raw uint8_t* pointer instead of push_back().
Pre-resize the buffer to include payload space before encoding.

Add ESPHOME_DEBUG_API bounds checks to validate writes stay within the
pre-sized region during development and integration testing.
2026-02-16 11:29:18 -06:00
J. Nick Koston
ab26e5d574 Merge remote-tracking branch 'origin/api-proto-write-presized-buffer' into integration 2026-02-16 11:20:30 -06:00
J. Nick Koston
ee9de5c412 [api] Write protobuf encode output to pre-sized buffer directly
ProtoSize::calculate_size() already computes the exact encoded size
before encode() runs and is the boundary validation. The buffer is
pre-sized to match. Since the buffer size is always correct,
push_back() capacity checks on every byte are redundant overhead.

Rename ProtoWriteBuffer to ProtoWritePreSizedBuffer to document the
contract. Write through a raw uint8_t* pointer instead of push_back().
Pre-resize the buffer to include payload space before encoding.

Add ESPHOME_DEBUG_API bounds checks to validate writes stay within the
pre-sized region during development and integration testing.
2026-02-16 11:10:10 -06:00
J. Nick Koston
b86cd229cc Merge remote-tracking branch 'upstream/api-remove-unused-reserve' into integration 2026-02-16 10:08:55 -06:00
J. Nick Koston
f40fa97883 [api] Remove unused reserve from APIServer constructor
All send paths already call prepare_first_message_buffer which does
clear() + reserve() with the exact needed size, making the initial
reserve(64) redundant. Removing it saves 68 bytes of flash.
2026-02-16 10:07:41 -06:00
J. Nick Koston
4a5639e9f7 Merge remote-tracking branch 'upstream/dev' into integration 2026-02-16 10:03:06 -06:00
J. Nick Koston
0c4827d348 [json, core] Remove stored RAMAllocator, make constructors constexpr (#14000) 2026-02-16 08:09:53 -06:00
J. Nick Koston
81872d9822 [camera, camera_encoder] Remove stored RAMAllocator member (#13997) 2026-02-16 08:09:26 -06:00
J. Nick Koston
ffb9a00e26 [online_image] Remove stored RAMAllocator member from DownloadBuffer (#13999) 2026-02-16 08:09:13 -06:00
J. Nick Koston
f2c827f9a2 [runtime_image] Remove stored RAMAllocator member (#13998) 2026-02-16 08:08:43 -06:00
J. Nick Koston
268dda8746 Merge branch 'json-remove-stored-allocator' into integration 2026-02-15 21:19:53 -06:00
J. Nick Koston
6ac6636127 Merge branch 'dev' into json-remove-stored-allocator 2026-02-15 20:58:32 -06:00
Cornelius A. Ludmann
f2cb5db9e0 [epaper_spi] Add Waveshare 7.5in e-Paper (H) (#13991) 2026-02-16 13:44:30 +11:00
Kevin Ahrendt
066419019f [audio] Support reallocating non-empty AudioTransferBuffer (#13979) 2026-02-15 16:09:35 -05:00
Pawelo
15da6d0a0b [epaper_spi] Add WeAct 3-color e-paper display support (#13894) 2026-02-16 07:58:51 +11:00
Jonathan Swoboda
6303bc3e35 [esp32_rmt] Handle ESP32 variants without RMT hardware (#14001)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 13:23:06 -05:00
Jonathan Swoboda
0f4dc6702d [fan] Fix preset_mode not restored on boot (#14002)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 12:11:50 -05:00
Jonathan Swoboda
f48c8a6444 [combination] Fix 'coeffecient' typo with backward-compatible deprecation (#14004)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 12:11:36 -05:00
J. Nick Koston
2f7b96a4a1 Merge branch 'camera-remove-stored-allocator' into integration 2026-02-14 16:00:18 -07:00
J. Nick Koston
3e0a117416 Merge branch 'runtime-image-remove-stored-allocator' into integration 2026-02-14 16:00:13 -07:00
J. Nick Koston
0fe2200689 Merge branch 'online-image-remove-stored-allocator' into integration 2026-02-14 16:00:07 -07:00
J. Nick Koston
d32f412c42 Merge remote-tracking branch 'origin/json-remove-stored-allocator' into integration 2026-02-14 15:59:56 -07:00
J. Nick Koston
062f223876 [json, core] Remove stored RAMAllocator, make constructors constexpr
RAMAllocator with default flags is stateless — it's just a dispatch
wrapper over heap_caps_malloc/realloc/free. Remove the stored member
from SpiRamAllocator, using stack-local instances at each call site.

Also make RAMAllocator constructors constexpr so the compiler can
fully evaluate flag logic at compile time.

Note: SpiRamAllocator was initialized with RAMAllocator::NONE (0),
which is equivalent to default construction since the constructor
preserves the default ALLOC_INTERNAL | ALLOC_EXTERNAL flags when
no valid allocation flags are provided.

Co-Authored-By: J. Nick Koston <nick@koston.org>
2026-02-14 15:43:50 -07:00
J. Nick Koston
6273ad6bf8 [online_image] Remove stored RAMAllocator member from DownloadBuffer
RAMAllocator with default flags is stateless — it's just a dispatch
wrapper over heap_caps_malloc/realloc/free. There's no need to store
it as a class member. Use stack-local instances at each call site
instead, matching the pattern used in audio_transfer_buffer and
ring_buffer.

Co-Authored-By: J. Nick Koston <nick@koston.org>
2026-02-14 15:35:05 -07:00
J. Nick Koston
be5f4845eb [runtime_image] Remove stored RAMAllocator member
RAMAllocator with default flags is stateless — it's just a dispatch
wrapper over heap_caps_malloc/realloc/free. There's no need to store
it as a class member. Use stack-local instances at each call site
instead, matching the pattern used in audio_transfer_buffer and
ring_buffer.

Co-Authored-By: J. Nick Koston <nick@koston.org>
2026-02-14 15:34:11 -07:00
J. Nick Koston
df3a36376d [camera, camera_encoder] Remove stored RAMAllocator member
RAMAllocator is stateless when using default flags — it's just a
dispatch wrapper over heap_caps_malloc/realloc/free. There's no need
to store it as a class member. Use stack-local instances at each call
site instead, matching the pattern used in audio_transfer_buffer and
ring_buffer.

Co-Authored-By: J. Nick Koston <nick@koston.org>
2026-02-14 15:32:11 -07:00
dependabot[bot]
38404b2013 Bump ruff from 0.15.0 to 0.15.1 (#13980)
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-14 15:11:17 -07:00
AndreKR
5a6d64814a [http_request] Improve TLS logging on ESP8266 (#13985) 2026-02-14 10:08:26 -07:00
J. Nick Koston
36776b40c2 [wifi] Fix ESP8266 DHCP state corruption from premature dhcp_renew() (#13983)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 08:21:04 -07:00