aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/ProfileData/Coverage/CoverageMapping.cpp')
-rw-r--r--llvm/lib/ProfileData/Coverage/CoverageMapping.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
index 18643c6..c713371 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -49,13 +49,10 @@ using namespace coverage;
#define DEBUG_TYPE "coverage-mapping"
Counter CounterExpressionBuilder::get(const CounterExpression &E) {
- auto It = ExpressionIndices.find(E);
- if (It != ExpressionIndices.end())
- return Counter::getExpression(It->second);
- unsigned I = Expressions.size();
- Expressions.push_back(E);
- ExpressionIndices[E] = I;
- return Counter::getExpression(I);
+ auto [It, Inserted] = ExpressionIndices.try_emplace(E, Expressions.size());
+ if (Inserted)
+ Expressions.push_back(E);
+ return Counter::getExpression(It->second);
}
void CounterExpressionBuilder::extractTerms(Counter C, int Factor,