forked from OSchip/llvm-project
[ADT] Add a much simpler loop to DenseMap::clear when the types are
POD-like and we can just splat the empty key across memory. Sadly we can't optimize the normal loop well enough because we can't turn the conditional store into an unconditional store according to the memory model. This loop actually showed up in a profile of code that was calling clear as a serious source of time. =[ llvm-svn: 310189
This commit is contained in:
parent
7e84697e59
commit
6b78bac9fb
|
@ -107,6 +107,11 @@ public:
|
|||
}
|
||||
|
||||
const KeyT EmptyKey = getEmptyKey(), TombstoneKey = getTombstoneKey();
|
||||
if (isPodLike<KeyT>::value && isPodLike<ValueT>::value) {
|
||||
// Use a simpler loop when these are trivial types.
|
||||
for (BucketT *P = getBuckets(), *E = getBucketsEnd(); P != E; ++P)
|
||||
P->getFirst() = EmptyKey;
|
||||
} else {
|
||||
unsigned NumEntries = getNumEntries();
|
||||
for (BucketT *P = getBuckets(), *E = getBucketsEnd(); P != E; ++P) {
|
||||
if (!KeyInfoT::isEqual(P->getFirst(), EmptyKey)) {
|
||||
|
@ -118,6 +123,7 @@ public:
|
|||
}
|
||||
}
|
||||
assert(NumEntries == 0 && "Node count imbalance!");
|
||||
}
|
||||
setNumEntries(0);
|
||||
setNumTombstones(0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue