From: Benjamin Kramer Date: Thu, 21 Jul 2016 12:06:31 +0000 (+0000) Subject: [GCOV] Remove a layer of indirection. X-Git-Tag: llvmorg-4.0.0-rc1~14649 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2a185a2547caccd5e969e2c5e704ee9733aaa2fc;p=platform%2Fupstream%2Fllvm.git [GCOV] Remove a layer of indirection. StringMap is designed to hold large values. No functionality change intended. llvm-svn: 276265 --- diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp index b4070b6..32beab7 100644 --- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -251,11 +251,7 @@ namespace { class GCOVBlock : public GCOVRecord { public: GCOVLines &getFile(StringRef Filename) { - GCOVLines *&Lines = LinesByFile[Filename]; - if (!Lines) { - Lines = new GCOVLines(Filename, os); - } - return *Lines; + return LinesByFile.emplace_second(Filename, Filename, os).first->second; } void addEdge(GCOVBlock &Successor) { @@ -264,9 +260,9 @@ namespace { void writeOut() { uint32_t Len = 3; - SmallVector *, 32> SortedLinesByFile; + SmallVector *, 32> SortedLinesByFile; for (auto &I : LinesByFile) { - Len += I.second->length(); + Len += I.second.length(); SortedLinesByFile.push_back(&I); } @@ -274,21 +270,17 @@ namespace { write(Len); write(Number); - std::sort(SortedLinesByFile.begin(), SortedLinesByFile.end(), - [](StringMapEntry *LHS, - StringMapEntry *RHS) { - return LHS->getKey() < RHS->getKey(); - }); + std::sort( + SortedLinesByFile.begin(), SortedLinesByFile.end(), + [](StringMapEntry *LHS, StringMapEntry *RHS) { + return LHS->getKey() < RHS->getKey(); + }); for (auto &I : SortedLinesByFile) - I->getValue()->writeOut(); + I->getValue().writeOut(); write(0); write(0); } - ~GCOVBlock() { - DeleteContainerSeconds(LinesByFile); - } - GCOVBlock(const GCOVBlock &RHS) : GCOVRecord(RHS), Number(RHS.Number) { // Only allow copy before edges and lines have been added. After that, // there are inter-block pointers (eg: edges) that won't take kindly to @@ -306,7 +298,7 @@ namespace { } uint32_t Number; - StringMap LinesByFile; + StringMap LinesByFile; SmallVector OutEdges; };