summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThorbjørn Lund Martsum <tmartsum@gmail.com>2012-02-20 16:11:31 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-21 12:52:00 +0100
commit13f3346d34c007727f60f9ee73805bcc0aa1c04b (patch)
tree2eac92376eedb198e491d221ebc1cfef93470f75
parenta4e4c3100780be27070c8916d25a9f7c461d1e11 (diff)
QHeaderView - create a union to save some space.
Beside saving some space it also ensures a bit faster vector operations (remove and insert memcpy) - and lower the risk for a cache-miss. (Many operations seems to be about 5-10% faster in the benchmark). Change-Id: If8109e2146c25f642015906375dfbb449706ce8e Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
-rw-r--r--src/widgets/itemviews/qheaderview_p.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h
index 4d1f4ba5a0..2c657221dd 100644
--- a/src/widgets/itemviews/qheaderview_p.h
+++ b/src/widgets/itemviews/qheaderview_p.h
@@ -287,8 +287,11 @@ public:
struct SectionSpan {
int size;
- mutable int calculated_startpos;
- mutable int tmpLogIdx;
+ union { // This union is made in order to save space and ensure good vector performance (on remove)
+ mutable int calculated_startpos; // <- this is the primary used member.
+ mutable int tmpLogIdx; // When one of these 'tmp'-members has been used we call
+ int tmpDataStreamSectionCount; // recalcSectionStartPos() or set sectionStartposRecalc to true
+ }; // to ensure that calculated_startpos will be calculated afterwards.
QHeaderView::ResizeMode resizeMode;
inline SectionSpan() : size(0), resizeMode(QHeaderView::Interactive) {}
inline SectionSpan(int length, QHeaderView::ResizeMode mode)
@@ -296,7 +299,6 @@ public:
inline int sectionSize() const { return size; }
inline int calculatedEndPos() const { return calculated_startpos + size; }
#ifndef QT_NO_DATASTREAM
- int tmpDataStreamSectionCount;
inline void write(QDataStream &out) const
{ out << size; out << 1; out << (int)resizeMode; }
inline void read(QDataStream &in)