[llvm-commits] CVS: llvm/lib/Support/FoldingSet.cpp
Chris Lattner
sabre at nondot.org
Wed Jan 31 21:33:37 PST 2007
Changes in directory llvm/lib/Support:
FoldingSet.cpp updated: 1.14 -> 1.15
---
Log message:
improve comments, add an assertion
---
Diffs of the changes: (+6 -3)
FoldingSet.cpp | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
Index: llvm/lib/Support/FoldingSet.cpp
diff -u llvm/lib/Support/FoldingSet.cpp:1.14 llvm/lib/Support/FoldingSet.cpp:1.15
--- llvm/lib/Support/FoldingSet.cpp:1.14 Wed Jan 31 15:27:38 2007
+++ llvm/lib/Support/FoldingSet.cpp Wed Jan 31 23:33:21 2007
@@ -226,6 +226,7 @@
/// 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 @@
/// 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.
More information about the llvm-commits
mailing list