[llvm-commits] [llvm] r157550 - /llvm/trunk/include/llvm/ADT/DenseMap.h
Benjamin Kramer
benny.kra at googlemail.com
Sun May 27 15:53:11 PDT 2012
Author: d0k
Date: Sun May 27 17:53:10 2012
New Revision: 157550
URL: http://llvm.org/viewvc/llvm-project?rev=157550&view=rev
Log:
DenseMap: Use an early exit when there is nothing to do in DestroyAll().
Modified:
llvm/trunk/include/llvm/ADT/DenseMap.h
Modified: llvm/trunk/include/llvm/ADT/DenseMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseMap.h?rev=157550&r1=157549&r2=157550&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/DenseMap.h (original)
+++ llvm/trunk/include/llvm/ADT/DenseMap.h Sun May 27 17:53:10 2012
@@ -273,6 +273,9 @@
private:
void DestroyAll() {
+ if (NumBuckets == 0) // Nothing to do.
+ return;
+
const KeyT EmptyKey = getEmptyKey(), TombstoneKey = getTombstoneKey();
for (BucketT *P = Buckets, *E = Buckets+NumBuckets; P != E; ++P) {
if (!KeyInfoT::isEqual(P->first, EmptyKey) &&
@@ -281,12 +284,10 @@
P->first.~KeyT();
}
- if (NumBuckets) {
#ifndef NDEBUG
- memset((void*)Buckets, 0x5a, sizeof(BucketT)*NumBuckets);
+ memset((void*)Buckets, 0x5a, sizeof(BucketT)*NumBuckets);
#endif
- operator delete(Buckets);
- }
+ operator delete(Buckets);
}
void CopyFrom(const DenseMap& other) {
More information about the llvm-commits
mailing list