[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.
This commit is contained in:
J. Nick Koston
2026-02-19 15:17:14 -06:00
parent 4e09370252
commit c47e779cbc

View File

@@ -276,10 +276,10 @@ float LightState::gamma_uncorrect_lut(float value) const {
return value;
uint16_t target = static_cast<uint16_t>(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;