mirror of
https://github.com/esphome/esphome.git
synced 2026-09-14 16:48:40 +00:00
[light] Force-inline LightCall::set_flag_/clear_flag_
Both are trivial bit operations on a uint16_t (one or/and on flags_), but without ESPHOME_ALWAYS_INLINE each call costs a call0/call8 plus the return/register-window rotation — more work than the body itself. validate_() invokes these ~8 times and transform_parameters_() adds more, so runtime benchmarks should reflect the elimination of the call overhead. Note: a previous attempt at this (#15402) was closed based on flash size deltas alone. This reopens the question with CodSpeed in-loop to measure actual runtime impact.
This commit is contained in:
@@ -222,7 +222,7 @@ class LightCall {
|
||||
inline bool get_save_() { return (this->flags_ & FLAG_SAVE) != 0; }
|
||||
|
||||
// Helper to set flag - defaults to true for common case
|
||||
void set_flag_(FieldFlags flag, bool value = true) {
|
||||
void set_flag_(FieldFlags flag, bool value = true) ESPHOME_ALWAYS_INLINE {
|
||||
if (value) {
|
||||
this->flags_ |= flag;
|
||||
} else {
|
||||
@@ -231,7 +231,7 @@ class LightCall {
|
||||
}
|
||||
|
||||
// Helper to clear flag - reduces code size for common case
|
||||
void clear_flag_(FieldFlags flag) { this->flags_ &= ~flag; }
|
||||
void clear_flag_(FieldFlags flag) ESPHOME_ALWAYS_INLINE { this->flags_ &= ~flag; }
|
||||
|
||||
// Helper to log unsupported feature and clear flag - reduces code duplication
|
||||
void log_and_clear_unsupported_(FieldFlags flag, const LogString *feature, bool use_color_mode_log);
|
||||
|
||||
Reference in New Issue
Block a user