Skip to content

Commit c4b1e19

Browse files
kazutakahirataDanielCChen
authored andcommitted
[lld] Avoid repeated hash lookups (NFC) (llvm#112299)
1 parent c846a39 commit c4b1e19

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lld/COFF/SymbolTable.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,13 +424,11 @@ static void reportProblemSymbols(
424424
if (!sym)
425425
continue;
426426
if (undefs.count(sym)) {
427-
auto it = firstDiag.find(sym);
428-
if (it == firstDiag.end()) {
429-
firstDiag[sym] = undefDiags.size();
427+
auto [it, inserted] = firstDiag.try_emplace(sym, undefDiags.size());
428+
if (inserted)
430429
undefDiags.push_back({sym, {{file, symIndex}}});
431-
} else {
430+
else
432431
undefDiags[it->second].files.push_back({file, symIndex});
433-
}
434432
}
435433
if (localImports)
436434
if (Symbol *imp = localImports->lookup(sym))

0 commit comments

Comments
 (0)