From 0e4ebfa405d71082a1b873d1e149a4c1e78bd387 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Tue, 1 Oct 2024 07:48:41 -0700 Subject: [PATCH] [ExecutionEngine] Avoid repeated hash lookups (NFC) (#110621) --- .../Orc/Debugging/VTuneSupportPlugin.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/llvm/lib/ExecutionEngine/Orc/Debugging/VTuneSupportPlugin.cpp b/llvm/lib/ExecutionEngine/Orc/Debugging/VTuneSupportPlugin.cpp index 30a9728c8c20e3..de02a20524b9cb 100644 --- a/llvm/lib/ExecutionEngine/Orc/Debugging/VTuneSupportPlugin.cpp +++ b/llvm/lib/ExecutionEngine/Orc/Debugging/VTuneSupportPlugin.cpp @@ -39,12 +39,12 @@ static VTuneMethodBatch getMethodBatch(LinkGraph &G, bool EmitDebugInfo) { auto GetStringIdx = [Deduplicator = StringMap(), &Batch](StringRef S) mutable { - auto I = Deduplicator.find(S); - if (I != Deduplicator.end()) - return I->second; - - Batch.Strings.push_back(S.str()); - return Deduplicator[S] = Batch.Strings.size(); + auto [I, Inserted] = Deduplicator.try_emplace(S); + if (Inserted) { + Batch.Strings.push_back(S.str()); + I->second = Batch.Strings.size(); + } + return I->second; }; for (auto Sym : G.defined_symbols()) { if (!Sym->isCallable())