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/util/qcompleter.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/util/qcompleter.cpp')
-rw-r--r-- | src/widgets/util/qcompleter.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index ba56f004b7..55ceeca919 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -1144,9 +1144,9 @@ void QCompleter::setFilterMode(Qt::MatchFlags filterMode) if (d->filterMode == filterMode) return; - if (filterMode != Qt::MatchStartsWith - && filterMode != Qt::MatchContains - && filterMode != Qt::MatchEndsWith) { + if (Q_UNLIKELY(filterMode != Qt::MatchStartsWith && + filterMode != Qt::MatchContains && + filterMode != Qt::MatchEndsWith)) { qWarning("Unhandled QCompleter::filterMode flag is used."); return; } @@ -1641,7 +1641,7 @@ int QCompleter::maxVisibleItems() const void QCompleter::setMaxVisibleItems(int maxItems) { Q_D(QCompleter); - if (maxItems < 0) { + if (Q_UNLIKELY(maxItems < 0)) { qWarning("QCompleter::setMaxVisibleItems: " "Invalid max visible items (%d) must be >= 0", maxItems); return; |