From b034a14dc589fecbbb1e0c807690910303ca82a3 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 15 Jun 2015 15:06:56 +0200 Subject: Replace some QList with QVector On 64-bit platforms, QVector uses only 50% of QList per-element memory. Change-Id: I3057781e7fb58007ea2619cc91965a626d01473b Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Lars Knoll --- src/gui/painting/qpainterpath.cpp | 6 +++--- src/gui/text/qtexttable.cpp | 16 ++++++++-------- src/gui/text/qtexttable_p.h | 2 +- src/widgets/itemviews/qtableview_p.h | 4 ++-- src/widgets/kernel/qaction_p.h | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index de88d19d18..ba14a45d4a 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -1653,7 +1653,7 @@ QList QPainterPath::toFillPolygons(const QTransform &matrix) const qDebug() << " bounds" << i << bounds.at(i); #endif - QVector< QList > isects; + QVector< QVector > isects; isects.resize(count); // find all intersections @@ -1681,7 +1681,7 @@ QList QPainterPath::toFillPolygons(const QTransform &matrix) const // flatten the sets of intersections for (int i=0; i ¤t_isects = isects.at(i); + const QVector ¤t_isects = isects.at(i); for (int j=0; j QPainterPath::toFillPolygons(const QTransform &matrix) const // Join the intersected subpaths as rewinded polygons for (int i=0; i &subpath_list = isects[i]; + const QVector &subpath_list = isects[i]; if (!subpath_list.isEmpty()) { QPolygonF buildUp; for (int j=0; jfragmentMap().position(fragment), pieceTable->fragmentMap()); - QList::ConstIterator it = std::lower_bound(cells.constBegin(), cells.constEnd(), helper); + const auto it = std::lower_bound(cells.constBegin(), cells.constEnd(), helper); if ((it == cells.constEnd()) || (helper < *it)) return -1; return it - cells.constBegin(); @@ -406,7 +406,7 @@ void QTextTablePrivate::fragmentAdded(QChar type, uint fragment) Q_ASSERT(cells.indexOf(fragment) == -1); const uint pos = pieceTable->fragmentMap().position(fragment); QFragmentFindHelper helper(pos, pieceTable->fragmentMap()); - QList::Iterator it = std::lower_bound(cells.begin(), cells.end(), helper); + auto it = std::lower_bound(cells.begin(), cells.end(), helper); cells.insert(it, fragment); if (!fragment_start || pos < pieceTable->fragmentMap().position(fragment_start)) fragment_start = fragment; @@ -616,7 +616,7 @@ QTextTableCell QTextTable::cellAt(int position) const return QTextTableCell(); QFragmentFindHelper helper(position, map); - QList::ConstIterator it = std::lower_bound(d->cells.begin(), d->cells.end(), helper); + auto it = std::lower_bound(d->cells.begin(), d->cells.end(), helper); if (it != d->cells.begin()) --it; @@ -755,7 +755,7 @@ void QTextTable::insertColumns(int pos, int num) QTextFormatCollection *c = p->formatCollection(); p->beginEditBlock(); - QList extendedSpans; + QVector extendedSpans; for (int i = 0; i < d->nRows; ++i) { int cell; if (i == d->nRows - 1 && pos == d->nCols) { @@ -890,7 +890,7 @@ void QTextTable::removeRows(int pos, int num) p->aboutToRemoveCell(cellAt(pos, 0).firstPosition(), cellAt(pos + num - 1, d->nCols - 1).lastPosition()); - QList touchedCells; + QVector touchedCells; for (int r = pos; r < pos + num; ++r) { for (int c = 0; c < d->nCols; ++c) { int cell = d->grid[r*d->nCols + c]; @@ -952,7 +952,7 @@ void QTextTable::removeColumns(int pos, int num) p->aboutToRemoveCell(cellAt(0, pos).firstPosition(), cellAt(d->nRows - 1, pos + num - 1).lastPosition()); - QList touchedCells; + QVector touchedCells; for (int r = 0; r < d->nRows; ++r) { for (int c = pos; c < pos + num; ++c) { int cell = d->grid[r*d->nCols + c]; @@ -1046,7 +1046,7 @@ void QTextTable::mergeCells(int row, int column, int numRows, int numCols) // find the position at which to insert the contents of the merged cells QFragmentFindHelper helper(origCellPosition, p->fragmentMap()); - QList::Iterator it = std::lower_bound(d->cells.begin(), d->cells.end(), helper); + const auto it = std::lower_bound(d->cells.begin(), d->cells.end(), helper); Q_ASSERT(it != d->cells.end()); Q_ASSERT(!(helper < *it)); Q_ASSERT(*it == cellFragment); @@ -1079,7 +1079,7 @@ void QTextTable::mergeCells(int row, int column, int numRows, int numCols) if (firstCellIndex == -1) { QFragmentFindHelper helper(pos, p->fragmentMap()); - QList::Iterator it = std::lower_bound(d->cells.begin(), d->cells.end(), helper); + const auto it = std::lower_bound(d->cells.begin(), d->cells.end(), helper); Q_ASSERT(it != d->cells.end()); Q_ASSERT(!(helper < *it)); Q_ASSERT(*it == fragment); diff --git a/src/gui/text/qtexttable_p.h b/src/gui/text/qtexttable_p.h index d6d806cec3..72d9d8c639 100644 --- a/src/gui/text/qtexttable_p.h +++ b/src/gui/text/qtexttable_p.h @@ -71,7 +71,7 @@ public: int findCellIndex(int fragment) const; - QList cells; + QVector cells; // symmetric to cells array and maps to indecs in grid, // used for fast-lookup for row/column by fragment mutable QVector cellIndices; diff --git a/src/widgets/itemviews/qtableview_p.h b/src/widgets/itemviews/qtableview_p.h index 71c3dd97fa..617ecb1642 100644 --- a/src/widgets/itemviews/qtableview_p.h +++ b/src/widgets/itemviews/qtableview_p.h @@ -187,8 +187,8 @@ public: int columnSectionAnchor; int columnResizeTimerID; int rowResizeTimerID; - QList columnsToUpdate; - QList rowsToUpdate; + QVector columnsToUpdate; + QVector rowsToUpdate; QHeaderView *horizontalHeader; QHeaderView *verticalHeader; QWidget *cornerWidget; diff --git a/src/widgets/kernel/qaction_p.h b/src/widgets/kernel/qaction_p.h index f43ab6c86e..84c6774141 100644 --- a/src/widgets/kernel/qaction_p.h +++ b/src/widgets/kernel/qaction_p.h @@ -91,7 +91,7 @@ public: QVariant userData; #ifndef QT_NO_SHORTCUT int shortcutId; - QList alternateShortcutIds; + QVector alternateShortcutIds; Qt::ShortcutContext shortcutContext; uint autorepeat : 1; #endif -- cgit v1.2.3