[ADT] Reduce the requirements for the simple loop in DenseMap::clear
authorBenjamin Kramer <benny.kra@googlemail.com>
Mon, 13 Apr 2020 17:28:20 +0000 (19:28 +0200)
committerBenjamin Kramer <benny.kra@googlemail.com>
Mon, 13 Apr 2020 17:33:45 +0000 (19:33 +0200)
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.

llvm/include/llvm/ADT/DenseMap.h

index 8d83f7e..df4f020 100644 (file)
@@ -119,9 +119,8 @@ public:
     }
 
     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 {