[llvm] 01df04f - [ADT] Reduce the requirements for the simple loop in DenseMap::clear
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 13 10:34:10 PDT 2020
Author: Benjamin Kramer
Date: 2020-04-13T19:33:45+02:00
New Revision: 01df04fb5984558d217c7b0cdd4bad67e2c5e5d3
URL: https://github.com/llvm/llvm-project/commit/01df04fb5984558d217c7b0cdd4bad67e2c5e5d3
DIFF: https://github.com/llvm/llvm-project/commit/01df04fb5984558d217c7b0cdd4bad67e2c5e5d3.diff
LOG: [ADT] Reduce the requirements for the simple loop in DenseMap::clear
We can use it when just the value doesn't require destruction. Empty
keys are safe to overwrite always. This gets the important case of
std::pair values.
Added:
Modified:
llvm/include/llvm/ADT/DenseMap.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index 8d83f7e5507f..df4f02024344 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -119,9 +119,8 @@ class DenseMapBase : public DebugEpochBase {
}
const KeyT EmptyKey = getEmptyKey(), TombstoneKey = getTombstoneKey();
- if (is_trivially_copyable<KeyT>::value &&
- is_trivially_copyable<ValueT>::value) {
- // Use a simpler loop when these are trivial types.
+ if (std::is_trivially_destructible<ValueT>::value) {
+ // Use a simpler loop when values don't need destruction.
for (BucketT *P = getBuckets(), *E = getBucketsEnd(); P != E; ++P)
P->getFirst() = EmptyKey;
} else {
More information about the llvm-commits
mailing list