From ffd3bb760eb5936f1f6d21b29ca61664c08077bd Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 23 Mar 2026 01:16:36 -1000 Subject: [PATCH 1/2] [light] Reorder LightState fields to eliminate padding Move restore_mode_ (uint8_t) next to next_write_ and is_transformer_active_ (both bool) so all three pack into a single 4-byte slot. Previously restore_mode_ sat alone at the end of the struct with 3 bytes of trailing padding. Saves 4 bytes per LightState instance. --- esphome/components/light/light_state.h | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/esphome/components/light/light_state.h b/esphome/components/light/light_state.h index b8d72cc8325..947436e4850 100644 --- a/esphome/components/light/light_state.h +++ b/esphome/components/light/light_state.h @@ -322,22 +322,6 @@ class LightState : public EntityBase, public Component { FixedVector effects_; /// Object used to store the persisted values of the light. ESPPreferenceObject rtc_; - /// Value for storing the index of the currently active effect. 0 if no effect is active - uint32_t active_effect_index_{}; - /// Default transition length for all transitions in ms. - uint32_t default_transition_length_{}; - /// Transition length to use for flash transitions. - uint32_t flash_transition_length_{}; - /// Gamma correction factor for the light. - float gamma_correct_{}; -#ifdef USE_LIGHT_GAMMA_LUT - const uint16_t *gamma_table_{nullptr}; -#endif // USE_LIGHT_GAMMA_LUT - - /// Whether the light value should be written in the next cycle. - bool next_write_{true}; - // for effects, true if a transformer (transition) is active. - bool is_transformer_active_ = false; /** Listeners for remote values changes. * @@ -361,6 +345,22 @@ class LightState : public EntityBase, public Component { /// Initial state of the light. optional initial_state_{}; + /// Value for storing the index of the currently active effect. 0 if no effect is active + uint32_t active_effect_index_{}; + /// Default transition length for all transitions in ms. + uint32_t default_transition_length_{}; + /// Transition length to use for flash transitions. + uint32_t flash_transition_length_{}; + /// Gamma correction factor for the light. + float gamma_correct_{}; +#ifdef USE_LIGHT_GAMMA_LUT + const uint16_t *gamma_table_{nullptr}; +#endif // USE_LIGHT_GAMMA_LUT + + /// Whether the light value should be written in the next cycle. + bool next_write_{true}; + // for effects, true if a transformer (transition) is active. + bool is_transformer_active_ = false; /// Restore mode of the light. LightRestoreMode restore_mode_; }; From c1b2b110c5e2e7fa1c23bba026a08e9652301588 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 23 Mar 2026 01:17:27 -1000 Subject: [PATCH 2/2] Use brace initialization for is_transformer_active_ --- esphome/components/light/light_state.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/light/light_state.h b/esphome/components/light/light_state.h index 947436e4850..ab7f2e4df85 100644 --- a/esphome/components/light/light_state.h +++ b/esphome/components/light/light_state.h @@ -360,7 +360,7 @@ class LightState : public EntityBase, public Component { /// Whether the light value should be written in the next cycle. bool next_write_{true}; // for effects, true if a transformer (transition) is active. - bool is_transformer_active_ = false; + bool is_transformer_active_{false}; /// Restore mode of the light. LightRestoreMode restore_mode_; };