summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Korpipaa <tomi.korpipaa@qt.io>2022-06-13 11:25:13 +0300
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-06-13 10:06:00 +0000
commit6226369b4a7c258d261ba22dd7d957815f5f5c12 (patch)
tree8e81d303793afe670a936e60cbf81e0d13b7c18d
parent6146941e9f81744c5f4b4b926a011ead931e9e54 (diff)
Improve performance on QXYModelMapper
Remove unused variable, which is populated by calls to QXYSeries points() in a loop. Additionally add variables for column() and row() to avoid repeated calls to those. Fixes: QTBUG-99190 Change-Id: I3659a571ff7ef57c3db693c599f35f15227201ea Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> (cherry picked from commit bf1eae298e30822dbace46ae126f462368abe791) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/charts/xychart/qxymodelmapper.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/charts/xychart/qxymodelmapper.cpp b/src/charts/xychart/qxymodelmapper.cpp
index 82e3875c..c1589d74 100644
--- a/src/charts/xychart/qxymodelmapper.cpp
+++ b/src/charts/xychart/qxymodelmapper.cpp
@@ -367,31 +367,32 @@ void QXYModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottom
blockSeriesSignals();
QModelIndex index;
- QPointF oldPoint;
QPointF newPoint;
+ int indexColumn = 0;
+ int indexRow = 0;
for (int row = topLeft.row(); row <= bottomRight.row(); row++) {
for (int column = topLeft.column(); column <= bottomRight.column(); column++) {
index = topLeft.sibling(row, column);
- if (m_orientation == Qt::Vertical && (index.column() == m_xSection || index.column() == m_ySection)) {
- if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) {
- QModelIndex xIndex = xModelIndex(index.row() - m_first);
- QModelIndex yIndex = yModelIndex(index.row() - m_first);
+ indexColumn = index.column();
+ indexRow = index.row();
+ if (m_orientation == Qt::Vertical && (indexColumn == m_xSection || indexColumn == m_ySection)) {
+ if (indexRow >= m_first && (m_count == - 1 || indexRow < m_first + m_count)) {
+ QModelIndex xIndex = xModelIndex(indexRow - m_first);
+ QModelIndex yIndex = yModelIndex(indexRow - m_first);
if (xIndex.isValid() && yIndex.isValid()) {
- oldPoint = m_series->points().at(index.row() - m_first);
newPoint.setX(valueFromModel(xIndex));
newPoint.setY(valueFromModel(yIndex));
- m_series->replace(index.row() - m_first, newPoint);
+ m_series->replace(indexRow - m_first, newPoint);
}
}
- } else if (m_orientation == Qt::Horizontal && (index.row() == m_xSection || index.row() == m_ySection)) {
- if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) {
- QModelIndex xIndex = xModelIndex(index.column() - m_first);
- QModelIndex yIndex = yModelIndex(index.column() - m_first);
+ } else if (m_orientation == Qt::Horizontal && (indexRow == m_xSection || indexRow == m_ySection)) {
+ if (indexColumn >= m_first && (m_count == - 1 || indexColumn < m_first + m_count)) {
+ QModelIndex xIndex = xModelIndex(indexColumn - m_first);
+ QModelIndex yIndex = yModelIndex(indexColumn - m_first);
if (xIndex.isValid() && yIndex.isValid()) {
- oldPoint = m_series->points().at(index.column() - m_first);
newPoint.setX(valueFromModel(xIndex));
newPoint.setY(valueFromModel(yIndex));
- m_series->replace(index.column() - m_first, newPoint);
+ m_series->replace(indexColumn - m_first, newPoint);
}
}
}