forked from OSchip/llvm-project
Microoptimize DenseMap::clear.
Cache NumEntries locally, it's only used in an assert and using the member variable prevents the compiler from eliminating the tombstone check for types with trivial destructors. No functionality change intended. llvm-svn: 234589
This commit is contained in:
parent
fb8afb8f81
commit
9b88fed323
|
@ -100,16 +100,18 @@ public:
|
|||
}
|
||||
|
||||
const KeyT EmptyKey = getEmptyKey(), TombstoneKey = getTombstoneKey();
|
||||
unsigned NumEntries = getNumEntries();
|
||||
for (BucketT *P = getBuckets(), *E = getBucketsEnd(); P != E; ++P) {
|
||||
if (!KeyInfoT::isEqual(P->getFirst(), EmptyKey)) {
|
||||
if (!KeyInfoT::isEqual(P->getFirst(), TombstoneKey)) {
|
||||
P->getSecond().~ValueT();
|
||||
decrementNumEntries();
|
||||
--NumEntries;
|
||||
}
|
||||
P->getFirst() = EmptyKey;
|
||||
}
|
||||
}
|
||||
assert(getNumEntries() == 0 && "Node count imbalance!");
|
||||
assert(NumEntries == 0 && "Node count imbalance!");
|
||||
setNumEntries(0);
|
||||
setNumTombstones(0);
|
||||
}
|
||||
|
||||
|
@ -257,7 +259,7 @@ public:
|
|||
const void *getPointerIntoBucketsArray() const { return getBuckets(); }
|
||||
|
||||
protected:
|
||||
DenseMapBase() {}
|
||||
DenseMapBase() = default;
|
||||
|
||||
void destroyAll() {
|
||||
if (getNumBuckets() == 0) // Nothing to do.
|
||||
|
|
Loading…
Reference in New Issue