making some parameters const, plus minor improvements

* changed some parameters to "pointer to const", so compiler can better optimize code size and performance -  because data behind a const pointer will never be modified by the called function.
* made setPixelColor `const`

* fixed a few potentially uninitialized local vars (the may have random values if not initialized)

* avoid shadowing "state" in handleSerial()
* plus a few very minor improvements
This commit is contained in:
Frank
2025-01-07 20:33:10 +01:00
committed by Damian Schneider
parent 90c2955a71
commit 013684b5ca
16 changed files with 57 additions and 57 deletions

View File

@@ -154,7 +154,7 @@ uint16_t IRAM_ATTR_YN Segment::XY(int x, int y) const
}
// raw setColor function without checks (checks are done in setPixelColorXY())
void IRAM_ATTR_YN Segment::_setPixelColorXY_raw(int& x, int& y, uint32_t& col) const
void IRAM_ATTR_YN Segment::_setPixelColorXY_raw(const int& x, const int& y, uint32_t& col) const
{
const int baseX = start + x;
const int baseY = startY + y;
@@ -179,7 +179,7 @@ void IRAM_ATTR_YN Segment::_setPixelColorXY_raw(int& x, int& y, uint32_t& col) c
}
}
void IRAM_ATTR_YN Segment::setPixelColorXY(int x, int y, uint32_t col)
void IRAM_ATTR_YN Segment::setPixelColorXY(int x, int y, uint32_t col) const
{
if (!isActive()) return; // not active
@@ -276,8 +276,8 @@ void Segment::blur2D(uint8_t blur_x, uint8_t blur_y, bool smear) {
if (!isActive()) return; // not active
const unsigned cols = vWidth();
const unsigned rows = vHeight();
uint32_t lastnew;
uint32_t last;
uint32_t lastnew = BLACK;
uint32_t last = BLACK;
if (blur_x) {
const uint8_t keepx = smear ? 255 : 255 - blur_x;
const uint8_t seepx = blur_x >> 1;