diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-09-21 20:14:15 +0200 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-09-24 19:03:02 +0000 |
commit | 8bd0e6709f733a4934f32b4bd455eb1a46ff02d6 (patch) | |
tree | 572ed982c4641db05256b78a178e53dcf459ad5c | |
parent | 6d648961c693a3b2319d9ea8974547bd2b4bbece (diff) |
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 <samuel.gaist@idiap.ch>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Luca Beldi <v.ronin@yahoo.it>
-rw-r--r-- | src/widgets/itemviews/qheaderview.cpp | 6 |
1 files 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<SectionItem>::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; } |