From 8bd0e6709f733a4934f32b4bd455eb1a46ff02d6 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 21 Sep 2018 20:14:15 +0200 Subject: QHeaderView: apply small optimization in recalcSectionStartPos() The loop in recalcSectionStartPos() calls QVector<>::constEnd() after every iteration which is not needed since the vector stays constant. Therefore use the new for loop syntax from c++11 so constEnd() is only called once which gives a small speedup, noticeable with large section counts. Change-Id: If318eec10c9ce234004a9922409fbdbc6409f2f8 Reviewed-by: Samuel Gaist Reviewed-by: Richard Moe Gustavsen Reviewed-by: Luca Beldi --- src/widgets/itemviews/qheaderview.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 3396a91dc5..2f276a7a8c 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -3877,9 +3877,9 @@ void QHeaderViewPrivate::updateDefaultSectionSizeFromStyle() void QHeaderViewPrivate::recalcSectionStartPos() const // linear (but fast) { int pixelpos = 0; - for (QVector::const_iterator i = sectionItems.constBegin(); i != sectionItems.constEnd(); ++i) { - i->calculated_startpos = pixelpos; // write into const mutable - pixelpos += i->size; + for (const SectionItem &i : sectionItems) { + i.calculated_startpos = pixelpos; // write into const mutable + pixelpos += i.size; } sectionStartposRecalc = false; } -- cgit v1.2.3