[llvm-commits] CVS: llvm/lib/Support/SmallPtrSet.cpp

Chris Lattner sabre at nondot.org
Tue Feb 6 17:11:42 PST 2007



Changes in directory llvm/lib/Support:

SmallPtrSet.cpp updated: 1.4 -> 1.5
---
Log message:

do not let the table fill up with tombstones.


---
Diffs of the changes:  (+5 -1)

 SmallPtrSet.cpp |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletion(-)


Index: llvm/lib/Support/SmallPtrSet.cpp
diff -u llvm/lib/Support/SmallPtrSet.cpp:1.4 llvm/lib/Support/SmallPtrSet.cpp:1.5
--- llvm/lib/Support/SmallPtrSet.cpp:1.4	Mon Feb  5 17:10:31 2007
+++ llvm/lib/Support/SmallPtrSet.cpp	Tue Feb  6 19:11:25 2007
@@ -32,7 +32,8 @@
   }
   
   // If more than 3/4 of the array is full, grow.
-  if (NumElements*4 >= CurArraySize*3)
+  if (NumElements*4 >= CurArraySize*3 ||
+      CurArraySize-(NumElements+NumTombstones) < CurArraySize/8)
     Grow();
   
   // Okay, we know we have space.  Find a hash bucket.
@@ -40,6 +41,8 @@
   if (*Bucket == Ptr) return false; // Already inserted, good.
   
   // Otherwise, insert it!
+  if (*Bucket == getTombstoneMarker())
+    --NumTombstones;
   *Bucket = Ptr;
   ++NumElements;  // Track density.
   return true;
@@ -69,6 +72,7 @@
   // Set this as a tombstone.
   *Bucket = getTombstoneMarker();
   --NumElements;
+  ++NumTombstones;
   return true;
 }
 






More information about the llvm-commits mailing list