Improve caching in ensureColumnAndRowData()

Change-Id: I02d9f818f8e1d6fcb8c25d1b73c08171cfc1f74d
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
This commit is contained in:
Jan Arve Saether 2014-01-15 15:29:50 +01:00 committed by The Qt Project
parent 603eac2dfb
commit 556c3209e2
2 changed files with 14 additions and 1 deletions

View File

@ -985,6 +985,8 @@ void QGridLayoutEngine::invalidate()
q_cachedEffectiveLastRows[Hor] = -1;
q_cachedEffectiveLastRows[Ver] = -1;
q_totalBoxesValid = false;
q_sizeHintValid[Hor] = false;
q_sizeHintValid[Ver] = false;
q_cachedSize = QSizeF();
q_cachedConstraintOrientation = UnknownConstraint;
}
@ -1528,12 +1530,22 @@ void QGridLayoutEngine::ensureColumnAndRowData(QGridLayoutRowData *rowData, QGri
Qt::Orientation orientation,
const QAbstractLayoutStyleInfo *styleInfo) const
{
const int o = (orientation == Qt::Vertical ? Ver : Hor);
if (q_sizeHintValid[o] && !colPositions && !colSizes) {
if (totalBox != &q_totalBoxes[o])
*totalBox = q_totalBoxes[o];
return;
}
rowData->reset(rowCount(orientation));
fillRowData(rowData, colPositions, colSizes, orientation, styleInfo);
const QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical];
rowData->distributeMultiCells(rowInfo);
*totalBox = rowData->totalBox(0, rowCount(orientation));
//We have items whose width depends on their height
if (!colPositions && !colSizes) {
q_totalBoxes[o] = *totalBox;
q_sizeHintValid[o] = true;
}
}
/**

View File

@ -458,6 +458,7 @@ private:
// Output
mutable QSizeF q_cachedSize;
mutable bool q_totalBoxesValid;
mutable bool q_sizeHintValid[NOrientations];
mutable QVector<qreal> q_xx;
mutable QVector<qreal> q_yy;
mutable QVector<qreal> q_widths;