From e139722e9d26379cba0a04de8520eb469c1e4c8b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 11 Feb 2026 08:11:31 -0600 Subject: [PATCH] [web_server] Remove unnecessary packed attribute from DeferredEvent DeferredEvent contains two pointers (void* + function pointer), which are already naturally 4-byte aligned on all ESPHome targets. The struct is 8 bytes with no padding regardless of packed. The packed attribute forces the compiler to use byte-by-byte loads and stores instead of word-aligned access, bloating deq_push_back_with_dedup_ from 163 to 317 bytes due to shift/mask/or sequences for every field access. The packed attribute was added in #7538 likely to guarantee the struct stayed at 8 bytes, but this is already the case without it since both fields are pointer-sized. --- esphome/components/web_server/web_server.h | 2 +- esphome/components/web_server_idf/web_server_idf.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/web_server/web_server.h b/esphome/components/web_server/web_server.h index 224c051ece..b0c39f279b 100644 --- a/esphome/components/web_server/web_server.h +++ b/esphome/components/web_server/web_server.h @@ -130,7 +130,7 @@ class DeferredUpdateEventSource : public AsyncEventSource { bool operator==(const DeferredEvent &test) const { return (source_ == test.source_ && message_generator_ == test.message_generator_); } - } __attribute__((packed)); + }; protected: // surface a couple methods from the base class diff --git a/esphome/components/web_server_idf/web_server_idf.h b/esphome/components/web_server_idf/web_server_idf.h index 1760544963..1e6651ed03 100644 --- a/esphome/components/web_server_idf/web_server_idf.h +++ b/esphome/components/web_server_idf/web_server_idf.h @@ -277,7 +277,7 @@ struct DeferredEvent { bool operator==(const DeferredEvent &test) const { return (source_ == test.source_ && message_generator_ == test.message_generator_); } -} __attribute__((packed)); +}; class AsyncEventSourceResponse { friend class AsyncEventSource;