[llvm] [sancov] Avoid repeated map lookups (NFC) (PR #113026)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 19 14:26:23 PDT 2024
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/113026
>From 0492febd5305df78eca88c6d63c3c75fa6f70cd0 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 18 Oct 2024 09:31:58 -0700
Subject: [PATCH] [sancov] Avoid repeated map lookups (NFC)
---
llvm/tools/sancov/sancov.cpp | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/llvm/tools/sancov/sancov.cpp b/llvm/tools/sancov/sancov.cpp
index 80f9996ba705ba..b969fc651e0c1c 100644
--- a/llvm/tools/sancov/sancov.cpp
+++ b/llvm/tools/sancov/sancov.cpp
@@ -961,10 +961,9 @@ static FunctionLocs resolveFunctions(const SymbolizedCoverage &Coverage,
continue;
auto P = std::make_pair(Loc.Line, Loc.Column);
- auto I = Result.find(Fn);
- if (I == Result.end() || I->second > P) {
- Result[Fn] = P;
- }
+ auto [It, Inserted] = Result.try_emplace(Fn, P);
+ if (!Inserted && It->second > P)
+ It->second = P;
}
}
return Result;
More information about the llvm-commits
mailing list