summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-02-06 23:58:55 +0100
committerMarc Mutz <marc.mutz@kdab.com>2015-02-12 09:58:35 +0000
commitddbf5f3c33d5a2bf190dd85133b3d9558ec22e4c (patch)
treef9e89539019327fa7251b4d1b57af9565b755fc6 /src/corelib/tools
parent1355ac5b05e41e132071ec0fd3f5d32a2625d9bc (diff)
QTzTimeZonePrivate: replace some inefficient QLists with QVectors (I)
Both QTzTransitionTime and QTzTransitionRule are larger than void*, so holding them in QLists is horribly inefficient. Fix by declaring them as primitive types (they just contains various integers) and holding them in QVector instead. While we're at it, make the equality operator for QTzTransitionRule a constexpr, noexcept non-member, and provide the inequality operator, too. As well as being faster, this also saves 1.5K of text size on optimized AMD64 builds. Change-Id: I37100522f19556101c334625818dcf8c9a712dd9 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qtimezoneprivate_p.h34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/corelib/tools/qtimezoneprivate_p.h b/src/corelib/tools/qtimezoneprivate_p.h
index 5371aa6211..609ed50c56 100644
--- a/src/corelib/tools/qtimezoneprivate_p.h
+++ b/src/corelib/tools/qtimezoneprivate_p.h
@@ -48,6 +48,7 @@
#include "qtimezone.h"
#include "qlocale_p.h"
+#include "qvector.h"
#ifdef QT_USE_ICU
#include <unicode/ucal.h>
@@ -261,6 +262,24 @@ private:
#endif // QT_USE_ICU
#if defined Q_OS_UNIX && !defined Q_OS_MAC && !defined Q_OS_ANDROID
+struct QTzTransitionTime
+{
+ qint64 atMSecsSinceEpoch;
+ quint8 ruleIndex;
+};
+Q_DECLARE_TYPEINFO(QTzTransitionTime, Q_PRIMITIVE_TYPE);
+struct QTzTransitionRule
+{
+ int stdOffset;
+ int dstOffset;
+ quint8 abbreviationIndex;
+};
+Q_DECLARE_TYPEINFO(QTzTransitionRule, Q_PRIMITIVE_TYPE);
+Q_DECL_CONSTEXPR inline bool operator==(const QTzTransitionRule &lhs, const QTzTransitionRule &rhs) Q_DECL_NOTHROW
+{ return lhs.stdOffset == rhs.stdOffset && lhs.dstOffset == rhs.dstOffset && lhs.abbreviationIndex == rhs.abbreviationIndex; }
+Q_DECL_CONSTEXPR inline bool operator!=(const QTzTransitionRule &lhs, const QTzTransitionRule &rhs) Q_DECL_NOTHROW
+{ return !operator==(lhs, rhs); }
+
class Q_AUTOTEST_EXPORT QTzTimeZonePrivate Q_DECL_FINAL : public QTimeZonePrivate
{
public:
@@ -305,20 +324,9 @@ public:
private:
void init(const QByteArray &ianaId);
- struct QTzTransitionTime {
- qint64 atMSecsSinceEpoch;
- quint8 ruleIndex;
- };
- struct QTzTransitionRule {
- int stdOffset;
- int dstOffset;
- quint8 abbreviationIndex;
- bool operator==(const QTzTransitionRule &other) { return (stdOffset == other.stdOffset
- && dstOffset == other.dstOffset && abbreviationIndex == other.abbreviationIndex); }
- };
Data dataForTzTransition(QTzTransitionTime tran) const;
- QList<QTzTransitionTime> m_tranTimes;
- QList<QTzTransitionRule> m_tranRules;
+ QVector<QTzTransitionTime> m_tranTimes;
+ QVector<QTzTransitionRule> m_tranRules;
QList<QByteArray> m_abbreviations;
#ifdef QT_USE_ICU
mutable QSharedDataPointer<QTimeZonePrivate> m_icu;