diff options
author | Chris Lattner <sabre@nondot.org> | 2007-02-01 05:33:21 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-02-01 05:33:21 +0000 |
commit | 0de4439ad1c4b105680afed521aa3b1820a61409 (patch) | |
tree | 5fe5de8741784e2b2e29f73fe45871e3370070cc /lib/Support/FoldingSet.cpp | |
parent | 94c002a190cd2e3a52b1510bc997e53d63af0b3b (diff) |
improve comments, add an assertion
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33750 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/FoldingSet.cpp')
-rw-r--r-- | lib/Support/FoldingSet.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Support/FoldingSet.cpp b/lib/Support/FoldingSet.cpp index 1d04abf4e4..1b0e81e466 100644 --- a/lib/Support/FoldingSet.cpp +++ b/lib/Support/FoldingSet.cpp @@ -226,6 +226,7 @@ FoldingSetImpl::Node *FoldingSetImpl::FindNodeOrInsertPos(const NodeID &ID, /// is not already in the map. InsertPos must be obtained from /// FindNodeOrInsertPos. void FoldingSetImpl::InsertNode(Node *N, void *InsertPos) { + assert(N->getNextInBucket() == 0); // Do we need to grow the hashtable? DEBUG(DOUT << "INSERT: " << N << '\n'); if (NumNodes+1 > NumBuckets*2) { @@ -256,16 +257,18 @@ void FoldingSetImpl::InsertNode(Node *N, void *InsertPos) { /// removed or false if the node was not in the folding set. bool FoldingSetImpl::RemoveNode(Node *N) { // Because each bucket is a circular list, we don't need to compute N's hash - // to remove it. Chase around the list until we find the node (or bucket) - // which points to N. + // to remove it. DEBUG(DOUT << "REMOVE: " << N << '\n'); void *Ptr = N->getNextInBucket(); if (Ptr == 0) return false; // Not in folding set. --NumNodes; + N->SetNextInBucket(0); + // Remember what N originally pointed to, either a bucket or another node. void *NodeNextPtr = Ptr; - N->SetNextInBucket(0); + + // Chase around the list until we find the node (or bucket) which points to N. while (true) { if (Node *NodeInBucket = GetNextPtr(Ptr, Buckets, NumBuckets)) { // Advance pointer. |