diff options
author | Jeff Cohen <jeffc@jolt-lang.org> | 2007-04-14 21:50:21 +0000 |
---|---|---|
committer | Jeff Cohen <jeffc@jolt-lang.org> | 2007-04-14 21:50:21 +0000 |
commit | ac58a16f8584f38198cc7800bd37a896125268b7 (patch) | |
tree | 71a0670716b312cd0d1fba5d858f937e76128038 /lib/Support/SmallPtrSet.cpp | |
parent | bbb2a7a2cf43eca2870a7063404930866136716f (diff) |
Fix PR1329.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36016 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/SmallPtrSet.cpp')
-rw-r--r-- | lib/Support/SmallPtrSet.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/Support/SmallPtrSet.cpp b/lib/Support/SmallPtrSet.cpp index 98d5bc99ad..61fad5ea50 100644 --- a/lib/Support/SmallPtrSet.cpp +++ b/lib/Support/SmallPtrSet.cpp @@ -141,5 +141,33 @@ void SmallPtrSetImpl::Grow() { } delete [] OldBuckets; + NumTombstones = 0; + } +} + +SmallPtrSetImpl::SmallPtrSetImpl(const SmallPtrSetImpl& that) { + NumElements = that.NumElements; + NumTombstones = 0; + if (that.isSmall()) { + CurArraySize = that.CurArraySize; + CurArray = &SmallArray[0]; + memcpy(CurArray, that.CurArray, sizeof(void*)*CurArraySize); + } else { + CurArraySize = that.NumElements < 64 ? 128 : that.NumElements*2; + CurArray = new void*[CurArraySize+1]; + memset(CurArray, -1, CurArraySize*sizeof(void*)); + + // The end pointer, always valid, is set to a valid element to help the + // iterator. + CurArray[CurArraySize] = 0; + + // Copy over all valid entries. + for (void **BucketPtr = that.CurArray, **E = that.CurArray+CurArraySize; + BucketPtr != E; ++BucketPtr) { + // Copy over the element if it is valid. + void *Elt = *BucketPtr; + if (Elt != getTombstoneMarker() && Elt != getEmptyMarker()) + *const_cast<void**>(FindBucketFor(Elt)) = Elt; + } } } |