summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2013-09-29 18:07:23 -0700
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-03 21:53:38 +0100
commit9fc0965d1930b32277dd3845cb94b650aec67ac8 (patch)
tree07e94df723e07c6eb37dd04901781450599b8bf3 /src/corelib/tools
parent28d77c24c2deec2eee8c735b299f0da792d75c9f (diff)
Repack structs with more than one padding hole
Sizes gained (measured on 64-bit systems) BezierEase: shrunk 8 bytes QRegExpCharClass: shrunk 8 bytes QRegularExpressionPrivate: shrunk 8 bytes QTimeLinePrivate: shrunk 8 bytes QUtcTimeZonePrivate: shrunk 8 bytes QTextStreamPrivate: shrunk 8 bytes QDirPrivate: shrunk 8 bytes QFileDevicePrivate: shrunk 8 bytes Not done: QRegExpEngine: 18 bytes in 6 holes (you deserve high memory usage if you're still using QRegExp) QTextBoundaryFinder: 8 bytes in 2 holes (public class) QIODevicePrivate: 6 bytes in 2 holes, but there's no gain in packing QProcessPrivate: too complex and my copy is modified QThreadData: awaiting change from Marc Change-Id: I2a388b5ce17dec0dafcef18ed2e80d0379aa7d1e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qeasingcurve.cpp8
-rw-r--r--src/corelib/tools/qregexp.cpp4
-rw-r--r--src/corelib/tools/qregularexpression.cpp7
-rw-r--r--src/corelib/tools/qtimeline.cpp10
-rw-r--r--src/corelib/tools/qtimezoneprivate.cpp8
-rw-r--r--src/corelib/tools/qtimezoneprivate_p.h4
6 files changed, 23 insertions, 18 deletions
diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp
index 5daf067c71..2708901866 100644
--- a/src/corelib/tools/qeasingcurve.cpp
+++ b/src/corelib/tools/qeasingcurve.cpp
@@ -432,14 +432,14 @@ struct BezierEase : public QEasingCurveFunction
qreal p3x, p3y;
};
- bool _init;
- bool _valid;
QVector<SingleCubicBezier> _curves;
- int _curveCount;
QVector<qreal> _intervals;
+ int _curveCount;
+ bool _init;
+ bool _valid;
BezierEase()
- : QEasingCurveFunction(InOut), _init(false), _valid(false), _curves(10), _intervals(10)
+ : QEasingCurveFunction(InOut), _curves(10), _intervals(10), _init(false), _valid(false)
{ }
void init()
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index 88499ad9d9..d2b5adc974 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -1045,12 +1045,12 @@ public:
#endif
private:
- uint c; // character classes
QVector<QRegExpCharClassRange> r; // character ranges
- bool n; // negative?
#ifndef QT_NO_REGEXP_OPTIM
QVector<int> occ1; // first-occurrence array
#endif
+ uint c; // character classes
+ bool n; // negative?
};
#else
struct QRegExpCharClass
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
index d5bd1dff00..e1cf82bb8c 100644
--- a/src/corelib/tools/qregularexpression.cpp
+++ b/src/corelib/tools/qregularexpression.cpp
@@ -813,8 +813,9 @@ struct QRegularExpressionPrivate : QSharedData
int captureIndexForName(const QString &name) const;
- QString pattern;
+ // sizeof(QSharedData) == 4, so start our members with an enum
QRegularExpression::PatternOptions patternOptions;
+ QString pattern;
// *All* of the following members are set managed while holding this mutex,
// except for isDirty which is set to true by QRegularExpression setters
@@ -889,7 +890,7 @@ QRegularExpression::QRegularExpression(QRegularExpressionPrivate &dd)
\internal
*/
QRegularExpressionPrivate::QRegularExpressionPrivate()
- : pattern(), patternOptions(0),
+ : patternOptions(0), pattern(),
mutex(),
compiledPattern(0), studyData(0),
errorString(0), errorOffset(-1),
@@ -919,7 +920,7 @@ QRegularExpressionPrivate::~QRegularExpressionPrivate()
*/
QRegularExpressionPrivate::QRegularExpressionPrivate(const QRegularExpressionPrivate &other)
: QSharedData(other),
- pattern(other.pattern), patternOptions(other.patternOptions),
+ patternOptions(other.patternOptions), pattern(other.pattern),
mutex(),
compiledPattern(0), studyData(0),
errorString(0),
diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp
index 976c03aef4..3619c9e986 100644
--- a/src/corelib/tools/qtimeline.cpp
+++ b/src/corelib/tools/qtimeline.cpp
@@ -53,13 +53,17 @@ class QTimeLinePrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QTimeLine)
public:
inline QTimeLinePrivate()
- : startTime(0), duration(1000), startFrame(0), endFrame(0),
+ : easingCurve(QEasingCurve::InOutSine),
+ startTime(0), duration(1000), startFrame(0), endFrame(0),
updateInterval(1000 / 25),
totalLoopCount(1), currentLoopCount(0), currentTime(0), timerId(0),
- direction(QTimeLine::Forward), easingCurve(QEasingCurve::InOutSine),
+ direction(QTimeLine::Forward),
state(QTimeLine::NotRunning)
{ }
+ QElapsedTimer timer;
+ QEasingCurve easingCurve;
+
int startTime;
int duration;
int startFrame;
@@ -70,10 +74,8 @@ public:
int currentTime;
int timerId;
- QElapsedTimer timer;
QTimeLine::Direction direction;
- QEasingCurve easingCurve;
QTimeLine::State state;
inline void setState(QTimeLine::State newState)
{
diff --git a/src/corelib/tools/qtimezoneprivate.cpp b/src/corelib/tools/qtimezoneprivate.cpp
index 08a5ce0861..ee34469c03 100644
--- a/src/corelib/tools/qtimezoneprivate.cpp
+++ b/src/corelib/tools/qtimezoneprivate.cpp
@@ -596,9 +596,11 @@ QUtcTimeZonePrivate::QUtcTimeZonePrivate(const QByteArray &zoneId, int offsetSec
}
QUtcTimeZonePrivate::QUtcTimeZonePrivate(const QUtcTimeZonePrivate &other)
- : QTimeZonePrivate(other), m_offsetFromUtc(other.m_offsetFromUtc), m_name(other.m_name),
- m_abbreviation(other.m_abbreviation), m_country(other.m_country),
- m_comment(other.m_comment)
+ : QTimeZonePrivate(other), m_name(other.m_name),
+ m_abbreviation(other.m_abbreviation),
+ m_comment(other.m_comment),
+ m_country(other.m_country),
+ m_offsetFromUtc(other.m_offsetFromUtc)
{
}
diff --git a/src/corelib/tools/qtimezoneprivate_p.h b/src/corelib/tools/qtimezoneprivate_p.h
index 108aec2654..4fbb3ff6e0 100644
--- a/src/corelib/tools/qtimezoneprivate_p.h
+++ b/src/corelib/tools/qtimezoneprivate_p.h
@@ -203,11 +203,11 @@ private:
const QString &abbreviation, QLocale::Country country,
const QString &comment);
- int m_offsetFromUtc;
QString m_name;
QString m_abbreviation;
- QLocale::Country m_country;
QString m_comment;
+ QLocale::Country m_country;
+ int m_offsetFromUtc;
};
#ifdef QT_USE_ICU