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-25 16:27:11 +0000 |
commit | 0325842b9926f87f22beb3b8dda32c20b2f994ec (patch) | |
tree | 304767b2ae69a9c506e5ce9eef391c414e4a6cf9 /src/widgets/accessible/itemviews.cpp | |
parent | 5645dc9f8a5264bde855d5b14c619198cfedf3a5 (diff) |
QtWidgets: use Q_UNLIKELY for every qWarning() (2)
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 accessible/,
effects/, kernel/, styles/ and itemviews/ 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 QWidgetPrivate::setWindowModified_helper(), 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.
In qDraw* (qdrawutil.cpp), simplified boolean
expressions (sometimes by skipping re-checking
conditions already checked in a previous guard clause).
Change-Id: I58be22be0a33522c2629a66c2f6c795771a99f3f
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/widgets/accessible/itemviews.cpp')
-rw-r--r-- | src/widgets/accessible/itemviews.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp index 1b724c9a17..a7c1c75066 100644 --- a/src/widgets/accessible/itemviews.cpp +++ b/src/widgets/accessible/itemviews.cpp @@ -132,7 +132,7 @@ QAccessibleInterface *QAccessibleTable::cellAt(int row, int column) const return 0; Q_ASSERT(role() != QAccessible::Tree); QModelIndex index = view()->model()->index(row, column, view()->rootIndex()); - if (!index.isValid()) { + if (Q_UNLIKELY(!index.isValid())) { qWarning() << "QAccessibleTable::cellAt: invalid index: " << index << " for " << view(); return 0; } @@ -505,7 +505,7 @@ QAccessibleInterface *QAccessibleTable::child(int logicalIndex) const if (!iface) { QModelIndex index = view()->model()->index(row, column, view()->rootIndex()); - if (!index.isValid()) { + if (Q_UNLIKELY(!index.isValid())) { qWarning() << "QAccessibleTable::child: Invalid index at: " << row << column; return 0; } @@ -666,7 +666,7 @@ QModelIndex QAccessibleTree::indexFromLogical(int row, int column) const return QModelIndex(); const QTreeView *treeView = qobject_cast<const QTreeView*>(view()); - if ((row < 0) || (column < 0) || (treeView->d_func()->viewItems.count() <= row)) { + if (Q_UNLIKELY(row < 0 || column < 0 || treeView->d_func()->viewItems.count() <= row)) { qWarning() << "QAccessibleTree::indexFromLogical: invalid index: " << row << column << " for " << treeView; return QModelIndex(); } @@ -776,7 +776,7 @@ int QAccessibleTree::indexOfChild(const QAccessibleInterface *iface) const QAccessibleInterface *QAccessibleTree::cellAt(int row, int column) const { QModelIndex index = indexFromLogical(row, column); - if (!index.isValid()) { + if (Q_UNLIKELY(!index.isValid())) { qWarning() << "Requested invalid tree cell: " << row << column; return 0; } @@ -835,7 +835,7 @@ bool QAccessibleTree::selectRow(int row) QAccessibleTableCell::QAccessibleTableCell(QAbstractItemView *view_, const QModelIndex &index_, QAccessible::Role role_) : /* QAccessibleSimpleEditableTextInterface(this), */ view(view_), m_index(index_), m_role(role_) { - if (!index_.isValid()) + if (Q_UNLIKELY(!index_.isValid())) qWarning() << "QAccessibleTableCell::QAccessibleTableCell with invalid index: " << index_; } |