Skip to content

Commit 3bddf85

Browse files
[sancov] Avoid repeated map lookups (NFC) (#113026)
1 parent b9cb9b3 commit 3bddf85

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

llvm/tools/sancov/sancov.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -961,10 +961,9 @@ static FunctionLocs resolveFunctions(const SymbolizedCoverage &Coverage,
961961
continue;
962962

963963
auto P = std::make_pair(Loc.Line, Loc.Column);
964-
auto I = Result.find(Fn);
965-
if (I == Result.end() || I->second > P) {
966-
Result[Fn] = P;
967-
}
964+
auto [It, Inserted] = Result.try_emplace(Fn, P);
965+
if (!Inserted && It->second > P)
966+
It->second = P;
968967
}
969968
}
970969
return Result;

0 commit comments

Comments
 (0)