Only repaint LcdWidget if necessary (#7187)
Some analysis done with Callgrind showed that the `LcdWidget` spends quite some time repainting itself even when nothing has changed. Some widget instances are used in song update contexts where `LcdWidget::setValue` is called 60 times per second. This commit fixes the problem by only updating the `LcdWidget` if its value really has changed. Adjust the condition in the if-clause so that it becomes clearer what's the interval of interest.
This commit is contained in:
committed by
GitHub
parent
c271d28314
commit
5d5d8f8f14
@@ -78,20 +78,26 @@ void LcdWidget::setValue(int value)
|
||||
}
|
||||
}
|
||||
|
||||
m_display = s;
|
||||
if (m_display != s)
|
||||
{
|
||||
m_display = s;
|
||||
|
||||
update();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void LcdWidget::setValue(float value)
|
||||
{
|
||||
if (value < 0 && value > -1)
|
||||
if (-1 < value && value < 0)
|
||||
{
|
||||
QString s = QString::number(static_cast<int>(value));
|
||||
s.prepend('-');
|
||||
|
||||
m_display = s;
|
||||
update();
|
||||
if (m_display != s)
|
||||
{
|
||||
m_display = s;
|
||||
update();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user