summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qmap.cpp
diff options
context:
space:
mode:
authorJerome Pasion <jerome.pasion@digia.com>2012-11-02 14:41:27 +0100
committerJerome Pasion <jerome.pasion@digia.com>2012-11-02 14:41:27 +0100
commitc808dd27459e030fde0577feb8ba06e3bd465526 (patch)
tree4bf898dc4a88e2b03c9716f940638a2e01c6c0ce /src/corelib/tools/qmap.cpp
parentd9d8845d507a6bdbc9c9f24c0d9d86dca513461d (diff)
parent300534fc214f2547a63594ce0891e9a54c8f33ca (diff)
Merge branch 'master' of ssh://codereview.qt-project.org/qt/qtbase into newdocs
Diffstat (limited to 'src/corelib/tools/qmap.cpp')
-rw-r--r--src/corelib/tools/qmap.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp
index dea87c6b63..7c33d60750 100644
--- a/src/corelib/tools/qmap.cpp
+++ b/src/corelib/tools/qmap.cpp
@@ -50,7 +50,7 @@
QT_BEGIN_NAMESPACE
-const QMapDataBase QMapDataBase::shared_null = { Q_REFCOUNT_INITIALIZE_STATIC, 0, { 0, 0, 0 } };
+const QMapDataBase QMapDataBase::shared_null = { Q_REFCOUNT_INITIALIZE_STATIC, 0, { 0, 0, 0 }, 0 };
const QMapNodeBase *QMapNodeBase::nextNode() const
{
@@ -177,6 +177,12 @@ void QMapDataBase::freeNodeAndRebalance(QMapNodeBase *z)
QMapNodeBase *x_parent;
if (y->left == 0) {
x = y->right;
+ if (y == mostLeftNode) {
+ if (x)
+ mostLeftNode = x; // It cannot have (left) children due the red black invariant.
+ else
+ mostLeftNode = y->parent();
+ }
} else {
if (y->right == 0) {
x = y->left;
@@ -290,6 +296,13 @@ void QMapDataBase::freeNodeAndRebalance(QMapNodeBase *z)
--size;
}
+void QMapDataBase::recalcMostLeftNode()
+{
+ mostLeftNode = &header;
+ while (mostLeftNode->left)
+ mostLeftNode = mostLeftNode->left;
+}
+
static inline int qMapAlignmentThreshold()
{
// malloc on 32-bit platforms should return pointers that are 8-byte
@@ -324,6 +337,8 @@ QMapNodeBase *QMapDataBase::createNode(int alloc, int alignment, QMapNodeBase *p
if (parent) {
if (left) {
parent->left = node;
+ if (parent == mostLeftNode)
+ mostLeftNode = node;
} else {
parent->right = node;
}
@@ -352,6 +367,7 @@ QMapDataBase *QMapDataBase::createData()
d->header.p = 0;
d->header.left = 0;
d->header.right = 0;
+ d->mostLeftNode = &(d->header);
return d;
}