Skip to content

Commit 0e4ebfa

Browse files
kazutakahirataSterling-Augustine
authored andcommitted
[ExecutionEngine] Avoid repeated hash lookups (NFC) (llvm#110621)
1 parent c92ec3d commit 0e4ebfa

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

llvm/lib/ExecutionEngine/Orc/Debugging/VTuneSupportPlugin.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ static VTuneMethodBatch getMethodBatch(LinkGraph &G, bool EmitDebugInfo) {
3939

4040
auto GetStringIdx = [Deduplicator = StringMap<uint32_t>(),
4141
&Batch](StringRef S) mutable {
42-
auto I = Deduplicator.find(S);
43-
if (I != Deduplicator.end())
44-
return I->second;
45-
46-
Batch.Strings.push_back(S.str());
47-
return Deduplicator[S] = Batch.Strings.size();
42+
auto [I, Inserted] = Deduplicator.try_emplace(S);
43+
if (Inserted) {
44+
Batch.Strings.push_back(S.str());
45+
I->second = Batch.Strings.size();
46+
}
47+
return I->second;
4848
};
4949
for (auto Sym : G.defined_symbols()) {
5050
if (!Sym->isCallable())

0 commit comments

Comments
 (0)