diff --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp index 82d14861e1e10..67aa71027687a 100644 --- a/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp +++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp @@ -155,29 +155,23 @@ class LVForwardReferences { } void add(StringRef Name, TypeIndex TIForward) { - if (ForwardTypesNames.find(Name) == ForwardTypesNames.end()) { - ForwardTypesNames.emplace( - std::piecewise_construct, std::forward_as_tuple(Name), - std::forward_as_tuple(TIForward, TypeIndex::None())); - } else { + auto [It, Inserted] = + ForwardTypesNames.try_emplace(Name, TIForward, TypeIndex::None()); + if (!Inserted) { // Update a recorded definition with its reference. - ForwardTypesNames[Name].first = TIForward; - add(TIForward, ForwardTypesNames[Name].second); + It->second.first = TIForward; + add(TIForward, It->second.second); } } // Update a previously recorded forward reference with its definition. void update(StringRef Name, TypeIndex TIReference) { - auto It = ForwardTypesNames.find(Name); - if (It != ForwardTypesNames.end()) { + auto [It, Inserted] = + ForwardTypesNames.try_emplace(Name, TypeIndex::None(), TIReference); + if (!Inserted) { // Update the recorded forward reference with its definition. It->second.second = TIReference; add(It->second.first, TIReference); - } else { - // We have not seen the forward reference. Insert the definition. - ForwardTypesNames.emplace( - std::piecewise_construct, std::forward_as_tuple(Name), - std::forward_as_tuple(TypeIndex::None(), TIReference)); } }