Skip to content

Commit e49c8d5

Browse files
[DebugInfo] Avoid repeated map lookups (NFC) (#128826)
1 parent bd9e31e commit e49c8d5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,9 @@ class LVStringRecords {
268268

269269
void add(TypeIndex TI, StringRef String) {
270270
static uint32_t Index = 0;
271-
if (Strings.find(TI) == Strings.end())
272-
Strings.emplace(
273-
std::piecewise_construct, std::forward_as_tuple(TI),
274-
std::forward_as_tuple(++Index, std::string(String), nullptr));
271+
auto [It, Inserted] = Strings.try_emplace(TI);
272+
if (Inserted)
273+
It->second = std::make_tuple(++Index, std::string(String), nullptr);
275274
}
276275

277276
StringRef find(TypeIndex TI) {

0 commit comments

Comments
 (0)