From: Pete Cooper Date: Wed, 19 Mar 2014 00:23:30 +0000 (+0000) Subject: When destroying a StringMap, just iterate over the map and destroy the contained... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f7efbb1906e58c3e8eed281c9b8ac7f2224b5ae7;p=oota-llvm.git When destroying a StringMap, just iterate over the map and destroy the contained elements. Don't reset them back to 0 as their values aren't needed any more. This results in ~StringMap() being mostly empty for POD types in BumpPtrAllocators git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204204 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h index c48f1ead023..4e74cf6529e 100644 --- a/include/llvm/ADT/StringMap.h +++ b/include/llvm/ADT/StringMap.h @@ -387,7 +387,17 @@ public: } ~StringMap() { - clear(); + // Delete all the elements in the map, but don't reset the elements + // to default values. This is a copy of clear(), but avoids unnecessary + // work not required in the destructor. + if (!empty()) { + for (unsigned I = 0, E = NumBuckets; I != E; ++I) { + StringMapEntryBase *Bucket = TheTable[I]; + if (Bucket && Bucket != getTombstoneVal()) { + static_cast(Bucket)->Destroy(Allocator); + } + } + } free(TheTable); } };