QTableView: don't convert QSet to QList just to iterate over it
Both in drawAndClipSpans(), as well as callee QSpanCollection::spansInRect(), a QSet is used to ensure uniqueness of elements. In both cases, the QSet is converted to QList, and the list is iterated over. Just iterate over the QSet directly... Change-Id: I8c7d17246a3cf836659026bfeadb987f37e476bb Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
0d88721d77
commit
04e4835a94
@ -169,7 +169,7 @@ void QSpanCollection::clear()
|
||||
/** \internal
|
||||
* return a list to all the spans that spans over cells in the given rectangle
|
||||
*/
|
||||
QList<QSpanCollection::Span *> QSpanCollection::spansInRect(int x, int y, int w, int h) const
|
||||
QSet<QSpanCollection::Span *> QSpanCollection::spansInRect(int x, int y, int w, int h) const
|
||||
{
|
||||
QSet<Span *> list;
|
||||
Index::const_iterator it_y = index.lowerBound(-y);
|
||||
@ -191,7 +191,7 @@ QList<QSpanCollection::Span *> QSpanCollection::spansInRect(int x, int y, int w,
|
||||
break;
|
||||
--it_y;
|
||||
}
|
||||
return list.values();
|
||||
return list;
|
||||
}
|
||||
|
||||
#undef DEBUG_SPAN_UPDATE
|
||||
@ -863,19 +863,17 @@ void QTableViewPrivate::drawAndClipSpans(const QRegion &area, QPainter *painter,
|
||||
bool alternateBase = false;
|
||||
QRegion region = viewport->rect();
|
||||
|
||||
QList<QSpanCollection::Span *> visibleSpans;
|
||||
QSet<QSpanCollection::Span *> visibleSpans;
|
||||
bool sectionMoved = verticalHeader->sectionsMoved() || horizontalHeader->sectionsMoved();
|
||||
|
||||
if (!sectionMoved) {
|
||||
visibleSpans = spans.spansInRect(logicalColumn(firstVisualColumn), logicalRow(firstVisualRow),
|
||||
lastVisualColumn - firstVisualColumn + 1, lastVisualRow - firstVisualRow + 1);
|
||||
} else {
|
||||
QSet<QSpanCollection::Span *> set;
|
||||
for(int x = firstVisualColumn; x <= lastVisualColumn; x++)
|
||||
for(int y = firstVisualRow; y <= lastVisualRow; y++)
|
||||
set.insert(spans.spanAt(x,y));
|
||||
set.remove(0);
|
||||
visibleSpans = set.values();
|
||||
visibleSpans.insert(spans.spanAt(x,y));
|
||||
visibleSpans.remove(nullptr);
|
||||
}
|
||||
|
||||
for (QSpanCollection::Span *span : qAsConst(visibleSpans)) {
|
||||
|
@ -104,7 +104,7 @@ public:
|
||||
void updateSpan(Span *span, int old_height);
|
||||
Span *spanAt(int x, int y) const;
|
||||
void clear();
|
||||
QList<Span *> spansInRect(int x, int y, int w, int h) const;
|
||||
QSet<Span *> spansInRect(int x, int y, int w, int h) const;
|
||||
|
||||
void updateInsertedRows(int start, int end);
|
||||
void updateInsertedColumns(int start, int end);
|
||||
|
Loading…
x
Reference in New Issue
Block a user