From a0f07cabcb82e5a3e8cb65d41e0eb2bf88e19505 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Sun, 29 Sep 2024 14:59:54 +0200 Subject: [PATCH] make a few getters "constexpr" as they just return a constant constexpr ensures that the compiler will replace the "getter" call with the value return, saving function call overhead. based on an idea from @blazoncek --- wled00/FX.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wled00/FX.h b/wled00/FX.h index 4e408254..04eabe70 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -951,13 +951,13 @@ class WS2812FX { // 96 bytes setPixelSegment(uint8_t n); inline uint8_t getBrightness(void) const { return _brightness; } - inline uint8_t getMaxSegments(void) const { return MAX_NUM_SEGMENTS; } // returns maximum number of supported segments (fixed value) inline uint8_t getSegmentsNum(void) const { return _segments.size(); } // returns currently present segments inline uint8_t getCurrSegmentId(void) const { return _segment_index; } inline uint8_t getMainSegmentId(void) const { return _mainSegment; } - inline uint8_t getPaletteCount() const { return 13 + GRADIENT_PALETTE_COUNT; } // will only return built-in palette count inline uint8_t getTargetFps() const { return _targetFps; } inline uint8_t getModeCount() const { return _modeCount; } + inline static constexpr uint8_t getMaxSegments(void) { return MAX_NUM_SEGMENTS; } // returns maximum number of supported segments (fixed value) + inline static constexpr uint8_t getPaletteCount() { return 13 + GRADIENT_PALETTE_COUNT; } // will only return built-in palette count uint16_t ablMilliampsMax,