From 0325842b9926f87f22beb3b8dda32c20b2f994ec Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 12 Nov 2015 10:16:22 +0100 Subject: 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 --- src/widgets/itemviews/qtableview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets/itemviews/qtableview.cpp') diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index 89bd9dbcb1..d0dcb02d7f 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -669,7 +669,7 @@ void QTableViewPrivate::trimHiddenSelections(QItemSelectionRange *range) const */ void QTableViewPrivate::setSpan(int row, int column, int rowSpan, int columnSpan) { - if (row < 0 || column < 0 || rowSpan <= 0 || columnSpan <= 0) { + if (Q_UNLIKELY(row < 0 || column < 0 || rowSpan <= 0 || columnSpan <= 0)) { qWarning("QTableView::setSpan: invalid span given: (%d, %d, %d, %d)", row, column, rowSpan, columnSpan); return; @@ -688,7 +688,7 @@ void QTableViewPrivate::setSpan(int row, int column, int rowSpan, int columnSpan sp->m_right = column + columnSpan - 1; spans.updateSpan(sp, old_height); return; - } else if (rowSpan == 1 && columnSpan == 1) { + } else if (Q_UNLIKELY(rowSpan == 1 && columnSpan == 1)) { qWarning("QTableView::setSpan: single cell span won't be added"); return; } -- cgit v1.2.3