mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-16 14:31:59 +00:00
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
This commit is contained in:
parent
04a3115e61
commit
e237cf934f
@ -51,6 +51,7 @@ protected:
|
|||||||
|
|
||||||
// If small, this is # elts allocated consequtively
|
// If small, this is # elts allocated consequtively
|
||||||
unsigned NumElements;
|
unsigned NumElements;
|
||||||
|
unsigned NumTombstones;
|
||||||
void *SmallArray[1]; // Must be last ivar.
|
void *SmallArray[1]; // Must be last ivar.
|
||||||
public:
|
public:
|
||||||
SmallPtrSetImpl(unsigned SmallSize) {
|
SmallPtrSetImpl(unsigned SmallSize) {
|
||||||
@ -82,6 +83,7 @@ public:
|
|||||||
// Fill the array with empty markers.
|
// Fill the array with empty markers.
|
||||||
memset(CurArray, -1, CurArraySize*sizeof(void*));
|
memset(CurArray, -1, CurArraySize*sizeof(void*));
|
||||||
NumElements = 0;
|
NumElements = 0;
|
||||||
|
NumTombstones = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// insert - This returns true if the pointer was new to the set, false if it
|
/// insert - This returns true if the pointer was new to the set, false if it
|
||||||
|
@ -32,7 +32,8 @@ bool SmallPtrSetImpl::insert(void *Ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If more than 3/4 of the array is full, grow.
|
// 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();
|
Grow();
|
||||||
|
|
||||||
// Okay, we know we have space. Find a hash bucket.
|
// 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.
|
if (*Bucket == Ptr) return false; // Already inserted, good.
|
||||||
|
|
||||||
// Otherwise, insert it!
|
// Otherwise, insert it!
|
||||||
|
if (*Bucket == getTombstoneMarker())
|
||||||
|
--NumTombstones;
|
||||||
*Bucket = Ptr;
|
*Bucket = Ptr;
|
||||||
++NumElements; // Track density.
|
++NumElements; // Track density.
|
||||||
return true;
|
return true;
|
||||||
@ -69,6 +72,7 @@ bool SmallPtrSetImpl::erase(void *Ptr) {
|
|||||||
// Set this as a tombstone.
|
// Set this as a tombstone.
|
||||||
*Bucket = getTombstoneMarker();
|
*Bucket = getTombstoneMarker();
|
||||||
--NumElements;
|
--NumElements;
|
||||||
|
++NumTombstones;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user