mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-28 09:31:03 +00:00
DenseMap: Factor destruction into a common helper method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157538 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b4654c1c49
commit
295d8ff007
@ -64,18 +64,7 @@ public:
|
||||
}
|
||||
|
||||
~DenseMap() {
|
||||
const KeyT EmptyKey = getEmptyKey(), TombstoneKey = getTombstoneKey();
|
||||
for (BucketT *P = Buckets, *E = Buckets+NumBuckets; P != E; ++P) {
|
||||
if (!KeyInfoT::isEqual(P->first, EmptyKey) &&
|
||||
!KeyInfoT::isEqual(P->first, TombstoneKey))
|
||||
P->second.~ValueT();
|
||||
P->first.~KeyT();
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
if (NumBuckets)
|
||||
memset((void*)Buckets, 0x5a, sizeof(BucketT)*NumBuckets);
|
||||
#endif
|
||||
operator delete(Buckets);
|
||||
DestroyAll();
|
||||
}
|
||||
|
||||
typedef DenseMapIterator<KeyT, ValueT, KeyInfoT> iterator;
|
||||
@ -254,9 +243,7 @@ public:
|
||||
const void *getPointerIntoBucketsArray() const { return Buckets; }
|
||||
|
||||
private:
|
||||
void CopyFrom(const DenseMap& other) {
|
||||
if (NumBuckets != 0 &&
|
||||
(!isPodLike<KeyT>::value || !isPodLike<ValueT>::value)) {
|
||||
void DestroyAll() {
|
||||
const KeyT EmptyKey = getEmptyKey(), TombstoneKey = getTombstoneKey();
|
||||
for (BucketT *P = Buckets, *E = Buckets+NumBuckets; P != E; ++P) {
|
||||
if (!KeyInfoT::isEqual(P->first, EmptyKey) &&
|
||||
@ -264,10 +251,6 @@ private:
|
||||
P->second.~ValueT();
|
||||
P->first.~KeyT();
|
||||
}
|
||||
}
|
||||
|
||||
NumEntries = other.NumEntries;
|
||||
NumTombstones = other.NumTombstones;
|
||||
|
||||
if (NumBuckets) {
|
||||
#ifndef NDEBUG
|
||||
@ -275,7 +258,13 @@ private:
|
||||
#endif
|
||||
operator delete(Buckets);
|
||||
}
|
||||
}
|
||||
|
||||
void CopyFrom(const DenseMap& other) {
|
||||
DestroyAll();
|
||||
|
||||
NumEntries = other.NumEntries;
|
||||
NumTombstones = other.NumTombstones;
|
||||
NumBuckets = other.NumBuckets;
|
||||
|
||||
if (NumBuckets == 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user