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>
This commit is contained in:
parent
a4e4c31007
commit
13f3346d34
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user