Bug 980934 (part 2) - MFBT: Remove the excessively frequent coherency checks from SplayTree. r=froydnj.

--HG--
extra : rebase_source : 4d0bd8e2d56771ee8ee4612ce3536bbdc23e958e
This commit is contained in:
Nicholas Nethercote 2014-07-30 16:21:06 -07:00
parent 290bcd9552
commit 83f6eeadee

View File

@ -73,7 +73,6 @@ public:
T* last = lookup(aValue);
splay(last);
checkCoherency(mRoot, nullptr);
return Comparator::compare(aValue, *last) == 0 ? last : nullptr;
}
@ -94,7 +93,6 @@ public:
aValue->mParent = last;
splay(aValue);
checkCoherency(mRoot, nullptr);
return true;
}
@ -154,7 +152,6 @@ public:
mRoot->mRight->mParent = mRoot;
}
checkCoherency(mRoot, nullptr);
return last;
}
@ -270,27 +267,29 @@ private:
T* checkCoherency(T* aNode, T* aMinimum)
{
#ifdef DEBUG
MOZ_ASSERT_IF(mRoot, !mRoot->mParent);
if (mRoot) {
MOZ_RELEASE_ASSERT(!mRoot->mParent);
}
if (!aNode) {
MOZ_ASSERT(!mRoot);
MOZ_RELEASE_ASSERT(!mRoot);
return nullptr;
}
MOZ_ASSERT_IF(!aNode->mParent, aNode == mRoot);
MOZ_ASSERT_IF(aMinimum, Comparator::compare(*aMinimum, *aNode) < 0);
if (!aNode->mParent) {
MOZ_RELEASE_ASSERT(aNode == mRoot);
}
if (aMinimum) {
MOZ_RELEASE_ASSERT(Comparator::compare(*aMinimum, *aNode) < 0);
}
if (aNode->mLeft) {
MOZ_ASSERT(aNode->mLeft->mParent == aNode);
MOZ_RELEASE_ASSERT(aNode->mLeft->mParent == aNode);
T* leftMaximum = checkCoherency(aNode->mLeft, aMinimum);
MOZ_ASSERT(Comparator::compare(*leftMaximum, *aNode) < 0);
MOZ_RELEASE_ASSERT(Comparator::compare(*leftMaximum, *aNode) < 0);
}
if (aNode->mRight) {
MOZ_ASSERT(aNode->mRight->mParent == aNode);
MOZ_RELEASE_ASSERT(aNode->mRight->mParent == aNode);
return checkCoherency(aNode->mRight, aNode);
}
return aNode;
#else
return nullptr;
#endif
}
SplayTree(const SplayTree&) MOZ_DELETE;