Skip to content

Commit b6f7428

Browse files
softhack007DedeHai
authored andcommitted
implement recommendations from reviewers
* simplified transition bugfix * removed cast same type * isIp parameter changed to pass-by-reference, to avoid copy constructor
1 parent 013684b commit b6f7428

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

wled00/FX.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ typedef struct Segment {
591591
void restoreSegenv(const tmpsegd_t &tmpSegD); // restores segment data from buffer, if buffer is not transition buffer, changed values are copied to transition buffer
592592
#endif
593593
[[gnu::hot]] void updateTransitionProgress(); // set current progression of transition
594-
inline uint16_t progress() const { return _transitionprogress; }; // transition progression between 0-65535
594+
inline uint16_t progress() const { return _t ? Segment::_transitionprogress : 0xFFFFU; } // transition progression between 0-65535
595595
[[gnu::hot]] uint8_t currentBri(bool useCct = false) const; // current segment brightness/CCT (blended while in transition)
596596
uint8_t currentMode() const; // currently active effect/mode (while in transition)
597597
[[gnu::hot]] uint32_t currentColor(uint8_t slot) const; // currently active segment color (blended while in transition)

wled00/FX_fcn.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ void Segment::restoreSegenv(const tmpsegd_t &tmpSeg) {
380380

381381
uint8_t Segment::currentBri(bool useCct) const {
382382
unsigned prog = progress();
383-
if (prog < 0xFFFFU && _t) {
383+
if (prog < 0xFFFFU) { // progress() < 0xFFFF inplies that _t is a valid pointer
384384
unsigned curBri = (useCct ? cct : (on ? opacity : 0)) * prog;
385385
curBri += (useCct ? _t->_cctT : _t->_briT) * (0xFFFFU - prog);
386386
return curBri / 0xFFFFU;
@@ -390,8 +390,8 @@ uint8_t Segment::currentBri(bool useCct) const {
390390

391391
uint8_t Segment::currentMode() const {
392392
#ifndef WLED_DISABLE_MODE_BLEND
393-
unsigned prog = progress();
394-
if (modeBlending && prog < 0xFFFFU && _t) return _t->_modeT;
393+
unsigned prog = progress(); // progress() < 0xFFFF inplies that _t is a valid pointer
394+
if (modeBlending && prog < 0xFFFFU) return _t->_modeT;
395395
#endif
396396
return mode;
397397
}

wled00/set.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -990,18 +990,18 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
990990
//set color from HEX or 32bit DEC
991991
pos = req.indexOf(F("CL="));
992992
if (pos > 0) {
993-
colorFromDecOrHexString(colIn, (const char*)req.substring(pos + 3).c_str());
993+
colorFromDecOrHexString(colIn, req.substring(pos + 3).c_str());
994994
col0Changed = true;
995995
}
996996
pos = req.indexOf(F("C2="));
997997
if (pos > 0) {
998-
colorFromDecOrHexString(colInSec, (const char*)req.substring(pos + 3).c_str());
998+
colorFromDecOrHexString(colInSec, req.substring(pos + 3).c_str());
999999
col1Changed = true;
10001000
}
10011001
pos = req.indexOf(F("C3="));
10021002
if (pos > 0) {
10031003
byte tmpCol[4];
1004-
colorFromDecOrHexString(tmpCol, (const char*)req.substring(pos + 3).c_str());
1004+
colorFromDecOrHexString(tmpCol, req.substring(pos + 3).c_str());
10051005
col2 = RGBW32(tmpCol[0], tmpCol[1], tmpCol[2], tmpCol[3]);
10061006
selseg.setColor(2, col2); // defined above (SS= or main)
10071007
col2Changed = true;

wled00/wled_server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static const char s_accessdenied[] PROGMEM = "Access Denied";
2121
static const char _common_js[] PROGMEM = "/common.js";
2222

2323
//Is this an IP?
24-
static bool isIp(const String str) {
24+
static bool isIp(const String &str) {
2525
for (size_t i = 0; i < str.length(); i++) {
2626
int c = str.charAt(i);
2727
if (c != '.' && (c < '0' || c > '9')) {

0 commit comments

Comments
 (0)