Skip to content

Commit 0089f39

Browse files
[ProfileData] Avoid repeated hash lookups (NFC) (llvm#110619)
1 parent ec61311 commit 0089f39

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

llvm/lib/ProfileData/Coverage/CoverageMapping.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,10 @@ using namespace coverage;
4949
#define DEBUG_TYPE "coverage-mapping"
5050

5151
Counter CounterExpressionBuilder::get(const CounterExpression &E) {
52-
auto It = ExpressionIndices.find(E);
53-
if (It != ExpressionIndices.end())
54-
return Counter::getExpression(It->second);
55-
unsigned I = Expressions.size();
56-
Expressions.push_back(E);
57-
ExpressionIndices[E] = I;
58-
return Counter::getExpression(I);
52+
auto [It, Inserted] = ExpressionIndices.try_emplace(E, Expressions.size());
53+
if (Inserted)
54+
Expressions.push_back(E);
55+
return Counter::getExpression(It->second);
5956
}
6057

6158
void CounterExpressionBuilder::extractTerms(Counter C, int Factor,

0 commit comments

Comments
 (0)