From c47e779cbcb4248172057d7494d9f03965673b4a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 19 Feb 2026 15:17:14 -0600 Subject: [PATCH] [light] Avoid unnecessary PROGMEM read in gamma_uncorrect_lut Move the lo >= 255 early return before the first table read so we don't waste a PROGMEM read that gets immediately discarded. --- esphome/components/light/light_state.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/light/light_state.cpp b/esphome/components/light/light_state.cpp index 42b996b2c7..d5735b4855 100644 --- a/esphome/components/light/light_state.cpp +++ b/esphome/components/light/light_state.cpp @@ -276,10 +276,10 @@ float LightState::gamma_uncorrect_lut(float value) const { return value; uint16_t target = static_cast(value * 65535.0f); uint8_t lo = gamma_table_reverse_search(this->gamma_table_, target); - // Interpolate between lo and lo+1 - uint16_t a = progmem_read_uint16(&this->gamma_table_[lo]); if (lo >= 255) return 1.0f; + // Interpolate between lo and lo+1 + uint16_t a = progmem_read_uint16(&this->gamma_table_[lo]); uint16_t b = progmem_read_uint16(&this->gamma_table_[lo + 1]); if (b == a) return lo / 255.0f;