From: Benjamin Kramer Date: Sun, 27 May 2012 22:53:10 +0000 (+0000) Subject: DenseMap: Use an early exit when there is nothing to do in DestroyAll(). X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=27f14297174bb203bee96fa8e5152f1f398389a1;p=platform%2Fupstream%2Fllvm.git DenseMap: Use an early exit when there is nothing to do in DestroyAll(). llvm-svn: 157550 --- diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h index 1fc0eed..0ceca92 100644 --- a/llvm/include/llvm/ADT/DenseMap.h +++ b/llvm/include/llvm/ADT/DenseMap.h @@ -273,6 +273,9 @@ public: 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 @@ private: 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) {