aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktableview_p_p.h
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2019-10-01 16:40:59 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-01-15 16:46:19 +0100
commite79a2658cde899d6ee11ec3c0d0a3768eb2c864b (patch)
tree79e7d1205cb44236f0ad082ff0c2e75e78046159 /src/quick/items/qquicktableview_p_p.h
parent4527d87e8f24e99658020900d9eb114d86d4dc82 (diff)
Use QFlatMap in QQuickTableView
QFlatMap is implemented to use two containers internally, one for keys and one for values. This improves locality of reference for the purpose of doing binary search to find a key quickly, and also makes the keys() (and values()) accessor really fast. Change-Id: I87bbb06371aeb44c5bcf971d72ae9cd59920f800 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/quick/items/qquicktableview_p_p.h')
-rw-r--r--src/quick/items/qquicktableview_p_p.h17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h
index ec043f5e7e..7c81882d44 100644
--- a/src/quick/items/qquicktableview_p_p.h
+++ b/src/quick/items/qquicktableview_p_p.h
@@ -54,6 +54,7 @@
#include "qquicktableview_p.h"
#include <QtCore/qtimer.h>
+#include <QtCore/private/qflatmap_p.h>
#include <QtQmlModels/private/qqmltableinstancemodel_p.h>
#include <QtQml/private/qqmlincubator_p.h>
#include <QtQmlModels/private/qqmlchangeset_p.h>
@@ -119,7 +120,7 @@ public:
qCDebug(lcTableViewDelegateLifecycle()) << "begin top-left:" << toString();
}
- void begin(Qt::Edge edgeToLoad, int edgeIndex, const QList<int> visibleCellsInEdge, QQmlIncubator::IncubationMode incubationMode)
+ void begin(Qt::Edge edgeToLoad, int edgeIndex, const QVector<int> visibleCellsInEdge, QQmlIncubator::IncubationMode incubationMode)
{
Q_ASSERT(!m_active);
m_active = true;
@@ -169,7 +170,7 @@ public:
private:
Qt::Edge m_edge = Qt::Edge(0);
- QList<int> m_visibleCellsInEdge;
+ QVector<int> m_visibleCellsInEdge;
int m_edgeIndex = 0;
int m_currentIndex = 0;
bool m_active = false;
@@ -246,8 +247,8 @@ public:
// we need to fill up with more rows/columns. loadedTableInnerRect describes the pixels
// that the loaded table covers if you remove one row/column on each side of the table, and
// is used to determine rows/columns that are no longer visible and can be unloaded.
- QMap<int, int> loadedColumns;
- QMap<int, int> loadedRows;
+ QFlatMap<int, int> loadedColumns;
+ QFlatMap<int, int> loadedRows;
QRectF loadedTableOuterRect;
QRectF loadedTableInnerRect;
@@ -333,10 +334,10 @@ public:
qreal getColumnWidth(int column);
qreal getRowHeight(int row);
- inline int topRow() const { return loadedRows.firstKey(); }
- inline int bottomRow() const { return loadedRows.lastKey(); }
- inline int leftColumn() const { return loadedColumns.firstKey(); }
- inline int rightColumn() const { return loadedColumns.lastKey(); }
+ inline int topRow() const { return loadedRows.cbegin().key(); }
+ inline int bottomRow() const { return (--loadedRows.cend()).key(); }
+ inline int leftColumn() const { return loadedColumns.cbegin().key(); }
+ inline int rightColumn() const { return (--loadedColumns.cend()).key(); }
QQuickTableView *rootSyncView() const;