summaryrefslogtreecommitdiff
path: root/lib/Support/SmallPtrSet.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-07 01:11:25 +0000
committerChris Lattner <sabre@nondot.org>2007-02-07 01:11:25 +0000
commite237cf934fcb8a25746e068f543fbd6db44eaa70 (patch)
treec4474877c0d1318c0f257ea7c598110066e61bb0 /lib/Support/SmallPtrSet.cpp
parent04a3115e619740245cbe34c8c7428b4bde7868f7 (diff)
downloadllvm-e237cf934fcb8a25746e068f543fbd6db44eaa70.tar.gz
llvm-e237cf934fcb8a25746e068f543fbd6db44eaa70.tar.bz2
llvm-e237cf934fcb8a25746e068f543fbd6db44eaa70.tar.xz
do not let the table fill up with tombstones.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33973 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/SmallPtrSet.cpp')
-rw-r--r--lib/Support/SmallPtrSet.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Support/SmallPtrSet.cpp b/lib/Support/SmallPtrSet.cpp
index 758a952ae4..98d5bc99ad 100644
--- a/lib/Support/SmallPtrSet.cpp
+++ b/lib/Support/SmallPtrSet.cpp
@@ -32,7 +32,8 @@ bool SmallPtrSetImpl::insert(void *Ptr) {
}
// 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 @@ bool SmallPtrSetImpl::insert(void *Ptr) {
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 @@ bool SmallPtrSetImpl::erase(void *Ptr) {
// Set this as a tombstone.
*Bucket = getTombstoneMarker();
--NumElements;
+ ++NumTombstones;
return true;
}