summaryrefslogtreecommitdiff
path: root/include/llvm
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2014-03-19 00:23:30 +0000
committerPete Cooper <peter_cooper@apple.com>2014-03-19 00:23:30 +0000
commitf7efbb1906e58c3e8eed281c9b8ac7f2224b5ae7 (patch)
treef58d76c86a83550ee21b05697710e4a64398f40e /include/llvm
parent025e94d7dc8611fa8f5704905636f07e5e95b6f4 (diff)
downloadllvm-f7efbb1906e58c3e8eed281c9b8ac7f2224b5ae7.tar.gz
llvm-f7efbb1906e58c3e8eed281c9b8ac7f2224b5ae7.tar.bz2
llvm-f7efbb1906e58c3e8eed281c9b8ac7f2224b5ae7.tar.xz
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
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/ADT/StringMap.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h
index c48f1ead02..4e74cf6529 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<MapEntryTy*>(Bucket)->Destroy(Allocator);
+ }
+ }
+ }
free(TheTable);
}
};