diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-11-12 10:16:22 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-11-21 14:26:07 +0000 |
commit | 496823b9a856d649c468d03b64241562807f3c16 (patch) | |
tree | 764f3128688f1d7a6f26a5909ad34b31712ae3a8 /src/widgets/widgets/qcombobox.cpp | |
parent | f5a650735ea6658a53b3783cc52fe3dcdef40698 (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/widgets/qcombobox.cpp')
-rw-r--r-- | src/widgets/widgets/qcombobox.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index deffad432f..401f365426 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -1360,7 +1360,7 @@ int QComboBox::maxVisibleItems() const void QComboBox::setMaxVisibleItems(int maxItems) { Q_D(QComboBox); - if (maxItems < 0) { + if (Q_UNLIKELY(maxItems < 0)) { qWarning("QComboBox::setMaxVisibleItems: " "Invalid max visible items (%d) must be >= 0", maxItems); return; @@ -1395,7 +1395,7 @@ int QComboBox::count() const void QComboBox::setMaxCount(int max) { Q_D(QComboBox); - if (max < 0) { + if (Q_UNLIKELY(max < 0)) { qWarning("QComboBox::setMaxCount: Invalid count (%d) must be >= 0", max); return; } @@ -1448,7 +1448,7 @@ void QComboBox::setAutoCompletion(bool enable) Q_D(QComboBox); #ifdef QT_KEYPAD_NAVIGATION - if (QApplication::keypadNavigationEnabled() && !enable && isEditable()) + if (Q_UNLIKELY(QApplication::keypadNavigationEnabled() && !enable && isEditable())) qWarning("QComboBox::setAutoCompletion: auto completion is mandatory when combo box editable"); #endif @@ -1758,7 +1758,7 @@ void QComboBox::setEditable(bool editable) void QComboBox::setLineEdit(QLineEdit *edit) { Q_D(QComboBox); - if (!edit) { + if (Q_UNLIKELY(!edit)) { qWarning("QComboBox::setLineEdit: cannot set a 0 line edit"); return; } @@ -1917,7 +1917,7 @@ QAbstractItemDelegate *QComboBox::itemDelegate() const */ void QComboBox::setItemDelegate(QAbstractItemDelegate *delegate) { - if (!delegate) { + if (Q_UNLIKELY(!delegate)) { qWarning("QComboBox::setItemDelegate: cannot set a 0 delegate"); return; } @@ -1949,7 +1949,7 @@ void QComboBox::setModel(QAbstractItemModel *model) { Q_D(QComboBox); - if (!model) { + if (Q_UNLIKELY(!model)) { qWarning("QComboBox::setModel: cannot set a 0 model"); return; } @@ -2395,7 +2395,7 @@ QAbstractItemView *QComboBox::view() const void QComboBox::setView(QAbstractItemView *itemView) { Q_D(QComboBox); - if (!itemView) { + if (Q_UNLIKELY(!itemView)) { qWarning("QComboBox::setView: cannot set a 0 view"); return; } |