identical expression

• Dec 29, 2020 - 15:57
Type
Functional
Frequency
Once
Severity
S4 - Minor
Reproducibility
Always
Status
closed
Regression
No
Workaround
No
Project

/src/importexport/internal/midiimport/importmidi_simplify.cpp line 44
Code:
ReducedFraction sum(0, 1);
for (const auto& d: durations) {
sum += ReducedFraction(d.second.fraction()) / d.first;
}
return desiredLen == desiredLen; // <-- identical expression


Comments

Same code in 3.x.
I guess (!) is rather should be return sum == desiredlen;, but I'm not really sure.
That function/method is used in some Q_ASSERT_X().

So that code is used only in DEBUG mode, never in any released version of MuseScore

only one more found:

[D:/Data/OpenSource/MuseScore-master/src/libmscore/textbase.cpp line 1983
Code:
if (r->height() == 0) {
r = &_layout[i - i].boundingRect(); // <- - same index
}

Hmm, r = &_layout[i-i].boundingRect(); is the same as r = &_layout[0].boundingRect();, but I wonder whether it is actually meant to be r = &_layout[i-1].boundingRect(); and whether that code just works by accident?
In 3.x too, but at libmscore/textbase.cpp, line1796

Came in via 10ebbb9080
Edit: no, that commit just moved it from text.cpp to textbase.cpp

Status PR created fixed

Fixed in branch 3.x, commit 08346483b0

_Fix #314899: Identical expression

by removing the entire thing, it seems useless, esp. that
return desiredLen == desiredLen; and even harmful and
wrong anyway._