summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs/qprogressdialog.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-11-12 10:16:22 +0100
committerMarc Mutz <marc.mutz@kdab.com>2015-11-21 14:26:07 +0000
commit496823b9a856d649c468d03b64241562807f3c16 (patch)
tree764f3128688f1d7a6f26a5909ad34b31712ae3a8 /src/widgets/dialogs/qprogressdialog.cpp
parentf5a650735ea6658a53b3783cc52fe3dcdef40698 (diff)
QtWidgets: use Q_UNLIKELY for every qWarning() (1)
If, after checking a condition, we issue a qWarning(), by definition that check is unlikely to be true. Tell the compiler so it can move the error handling code out of the normal code path to increase the effective icache size. This change contains the changes to the util/, dialogs/ and widgets/ subdirs. Moved conditional code around where possible so that we could always use Q_UNLIKELY, instead of having to revert to Q_LIKELY here and there. In QSystemTrayIcon::setVisible(), as a drive-by, I swapped the evaluation order of an &&-expression (newly wrapped in Q_UNLIKELY) to be more readable and more efficient (cheaper check first) at the same time. Change-Id: I3564c5a5deacba49d67d3989fb0b53e680c57fcb Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/widgets/dialogs/qprogressdialog.cpp')
-rw-r--r--src/widgets/dialogs/qprogressdialog.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp
index bbb251c8b2..619d0051ea 100644
--- a/src/widgets/dialogs/qprogressdialog.cpp
+++ b/src/widgets/dialogs/qprogressdialog.cpp
@@ -353,7 +353,7 @@ void QProgressDialog::setLabel(QLabel *label)
{
Q_D(QProgressDialog);
if (label == d->label) {
- if (label)
+ if (Q_UNLIKELY(label))
qWarning("QProgressDialog::setLabel: Attempt to set the same label again");
return;
}
@@ -402,7 +402,7 @@ void QProgressDialog::setCancelButton(QPushButton *cancelButton)
{
Q_D(QProgressDialog);
if (d->cancel == cancelButton) {
- if (cancelButton)
+ if (Q_UNLIKELY(cancelButton))
qWarning("QProgressDialog::setCancelButton: Attempt to set the same button again");
return;
}
@@ -465,16 +465,16 @@ void QProgressDialogPrivate::setCancelButtonText(const QString &cancelButtonText
void QProgressDialog::setBar(QProgressBar *bar)
{
Q_D(QProgressDialog);
- if (!bar) {
+ if (Q_UNLIKELY(!bar)) {
qWarning("QProgressDialog::setBar: Cannot set a null progress bar");
return;
}
#ifndef QT_NO_DEBUG
- if (value() > 0)
+ if (Q_UNLIKELY(value() > 0))
qWarning("QProgressDialog::setBar: Cannot set a new progress bar "
"while the old one is active");
#endif
- if (bar == d->bar) {
+ if (Q_UNLIKELY(bar == d->bar)) {
qWarning("QProgressDialog::setBar: Attempt to set the same progress bar again");
return;
}