diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2011-09-09 11:08:25 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-09-26 07:50:20 +0200 |
commit | 564086b366427da27eb1573e82fda7ab62dc4a17 (patch) | |
tree | 46a1d6334f46ba1d7d4321f4e47829edea531453 /src | |
parent | cc3bf12ef69c086069835585f298fe603e632aed (diff) |
Make QMapData::shared_null const
Similar to QVector, QByteArray and QString, keep the shared_null in
shareable memory and never modify it.
Change-Id: I062825684b79f2b01ec7ce65e0cf74f417b760b8
Reviewed-on: http://codereview.qt-project.org/4530
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qmap.cpp | 8 | ||||
-rw-r--r-- | src/corelib/tools/qmap.h | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp index aecc73c8dd..bd7c76c37a 100644 --- a/src/corelib/tools/qmap.cpp +++ b/src/corelib/tools/qmap.cpp @@ -50,10 +50,10 @@ QT_BEGIN_NAMESPACE -QMapData QMapData::shared_null = { - &shared_null, - { &shared_null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, 0, false, true, false, 0 +const QMapData QMapData::shared_null = { + const_cast<QMapData *>(&shared_null), + { const_cast<QMapData *>(&shared_null), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + Q_REFCOUNT_INITIALIZER(-1), 0, 0, 0, false, true, false, 0 }; QMapData *QMapData::createData() diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 771959a3bf..ff181d5071 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -42,9 +42,9 @@ #ifndef QMAP_H #define QMAP_H -#include <QtCore/qatomic.h> #include <QtCore/qiterator.h> #include <QtCore/qlist.h> +#include <QtCore/qrefcount.h> #ifndef QT_NO_STL #include <map> @@ -68,7 +68,7 @@ struct Q_CORE_EXPORT QMapData QMapData *backward; QMapData *forward[QMapData::LastLevel + 1]; - QBasicAtomicInt ref; + QtPrivate::RefCount ref; int topLevel; int size; uint randomBits; @@ -88,7 +88,7 @@ struct Q_CORE_EXPORT QMapData void dump(); #endif - static QMapData shared_null; + static const QMapData shared_null; }; @@ -179,7 +179,7 @@ class QMap } public: - inline QMap() : d(&QMapData::shared_null) { d->ref.ref(); } + inline QMap() : d(const_cast<QMapData *>(&QMapData::shared_null)) { } inline QMap(const QMap<Key, T> &other) : d(other.d) { d->ref.ref(); if (!d->sharable) detach(); } inline ~QMap() { if (!d) return; if (!d->ref.deref()) freeData(d); } |