[llvm-commits] CVS: llvm/lib/Support/SmallPtrSet.cpp
Jeff Cohen
jeffc at jolt-lang.org
Sat Apr 14 14:50:49 PDT 2007
Changes in directory llvm/lib/Support:
SmallPtrSet.cpp updated: 1.5 -> 1.6
---
Log message:
Fix PR1329: http://llvm.org/PR1329 .
---
Diffs of the changes: (+28 -0)
SmallPtrSet.cpp | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+)
Index: llvm/lib/Support/SmallPtrSet.cpp
diff -u llvm/lib/Support/SmallPtrSet.cpp:1.5 llvm/lib/Support/SmallPtrSet.cpp:1.6
--- llvm/lib/Support/SmallPtrSet.cpp:1.5 Tue Feb 6 19:11:25 2007
+++ llvm/lib/Support/SmallPtrSet.cpp Sat Apr 14 16:50:21 2007
@@ -141,5 +141,33 @@
}
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;
+ }
}
}
More information about the llvm-commits
mailing list