From 81a45e1f13fdf56129aed952a6e3479e16c14a2c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 26 Jul 2014 01:43:18 +0200 Subject: QTimeZone: don't use QSet, use sorted QList QSet, as a node-based container, requires one memory allocation per element inserted. QList, as a contiguous-memory container (at least in the case of a QByteArray payload), requires one memory allocation per container. The higher lookup speed might still speak for using QSet, but there are only two uses of the sets: 1. Checking for existence (or lack thereof) of timezone names. For this, first generating a container full of data just to check for existence of one item of data is extremely wasteful. The QTZPrivate API should be extended to allow said lookup to be performed on the native data store instead. That leaves 2. Returning a sorted(!) list(!) from the public QTimeZone API. There is no reason why, during the construction of those sorted lists, the data should be held in a set. Instead, the well-known technique of first cramming everything into a result container, which is subsequently sorted and has its duplicates removed, can be used here. Saves more than 8K of text size on AMD64 stripped release builds. Change-Id: I71c2298e94e02d55b0c9fb6f7ebeaed79a1fe2db Reviewed-by: Thiago Macieira --- src/corelib/tools/qtimezoneprivate_p.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/corelib/tools/qtimezoneprivate_p.h') diff --git a/src/corelib/tools/qtimezoneprivate_p.h b/src/corelib/tools/qtimezoneprivate_p.h index 609ed50c56..64827950e2 100644 --- a/src/corelib/tools/qtimezoneprivate_p.h +++ b/src/corelib/tools/qtimezoneprivate_p.h @@ -126,9 +126,9 @@ public: virtual QByteArray systemTimeZoneId() const; - virtual QSet availableTimeZoneIds() const; - virtual QSet availableTimeZoneIds(QLocale::Country country) const; - virtual QSet availableTimeZoneIds(int utcOffset) const; + virtual QList availableTimeZoneIds() const; + virtual QList availableTimeZoneIds(QLocale::Country country) const; + virtual QList availableTimeZoneIds(int utcOffset) const; virtual void serialize(QDataStream &ds) const; @@ -199,9 +199,9 @@ public: QByteArray systemTimeZoneId() const Q_DECL_OVERRIDE; - QSet availableTimeZoneIds() const Q_DECL_OVERRIDE; - QSet availableTimeZoneIds(QLocale::Country country) const Q_DECL_OVERRIDE; - QSet availableTimeZoneIds(int utcOffset) const Q_DECL_OVERRIDE; + QList availableTimeZoneIds() const Q_DECL_OVERRIDE; + QList availableTimeZoneIds(QLocale::Country country) const Q_DECL_OVERRIDE; + QList availableTimeZoneIds(int utcOffset) const Q_DECL_OVERRIDE; void serialize(QDataStream &ds) const Q_DECL_OVERRIDE; @@ -250,9 +250,9 @@ public: QByteArray systemTimeZoneId() const Q_DECL_OVERRIDE; - QSet availableTimeZoneIds() const Q_DECL_OVERRIDE; - QSet availableTimeZoneIds(QLocale::Country country) const Q_DECL_OVERRIDE; - QSet availableTimeZoneIds(int offsetFromUtc) const Q_DECL_OVERRIDE; + QList availableTimeZoneIds() const Q_DECL_OVERRIDE; + QList availableTimeZoneIds(QLocale::Country country) const Q_DECL_OVERRIDE; + QList availableTimeZoneIds(int offsetFromUtc) const Q_DECL_OVERRIDE; private: void init(const QByteArray &ianaId); @@ -318,8 +318,8 @@ public: QByteArray systemTimeZoneId() const Q_DECL_OVERRIDE; - QSet availableTimeZoneIds() const Q_DECL_OVERRIDE; - QSet availableTimeZoneIds(QLocale::Country country) const Q_DECL_OVERRIDE; + QList availableTimeZoneIds() const Q_DECL_OVERRIDE; + QList availableTimeZoneIds(QLocale::Country country) const Q_DECL_OVERRIDE; private: void init(const QByteArray &ianaId); @@ -369,7 +369,7 @@ public: QByteArray systemTimeZoneId() const Q_DECL_OVERRIDE; - QSet availableTimeZoneIds() const Q_DECL_OVERRIDE; + QList availableTimeZoneIds() const Q_DECL_OVERRIDE; private: void init(const QByteArray &zoneId); @@ -420,7 +420,7 @@ public: QByteArray systemTimeZoneId() const Q_DECL_OVERRIDE; - QSet availableTimeZoneIds() const Q_DECL_OVERRIDE; + QList availableTimeZoneIds() const Q_DECL_OVERRIDE; private: void init(const QByteArray &ianaId); -- cgit v1.2.3