From a3264940106db05c8acb74cc3931240b8eb8f42e Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Tue, 25 Feb 2025 09:08:47 -0800 Subject: [PATCH] [DebugInfo] Avoid repeated map lookups (NFC) --- .../DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp index 67aa71027687a..97214948d014a 100644 --- a/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp +++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp @@ -268,10 +268,9 @@ class LVStringRecords { void add(TypeIndex TI, StringRef String) { static uint32_t Index = 0; - if (Strings.find(TI) == Strings.end()) - Strings.emplace( - std::piecewise_construct, std::forward_as_tuple(TI), - std::forward_as_tuple(++Index, std::string(String), nullptr)); + auto [It, Inserted] = Strings.try_emplace(TI); + if (Inserted) + It->second = std::make_tuple(++Index, std::string(String), nullptr); } StringRef find(TypeIndex TI) {