[llvm] 60a6e6f - [Object] Avoid repeated map lookups (NFC) (#110201)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 28 10:03:26 PDT 2024
Author: Kazu Hirata
Date: 2024-09-28T10:03:23-07:00
New Revision: 60a6e6fa54b79d0771f36b4f9565cb6b465b7501
URL: https://github.com/llvm/llvm-project/commit/60a6e6fa54b79d0771f36b4f9565cb6b465b7501
DIFF: https://github.com/llvm/llvm-project/commit/60a6e6fa54b79d0771f36b4f9565cb6b465b7501.diff
LOG: [Object] Avoid repeated map lookups (NFC) (#110201)
Added:
Modified:
llvm/lib/Object/ArchiveWriter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Object/ArchiveWriter.cpp b/llvm/lib/Object/ArchiveWriter.cpp
index 114045561366d7..c61ba868efe60e 100644
--- a/llvm/lib/Object/ArchiveWriter.cpp
+++ b/llvm/lib/Object/ArchiveWriter.cpp
@@ -754,9 +754,8 @@ static Expected<std::vector<unsigned>> getSymbols(SymbolicFile *Obj,
raw_string_ostream NameStream(Name);
if (Error E = S.printName(NameStream))
return std::move(E);
- if (Map->find(Name) != Map->end())
+ if (!Map->try_emplace(Name, Index).second)
continue; // ignore duplicated symbol
- (*Map)[Name] = Index;
if (Map == &SymMap->Map) {
Ret.push_back(SymNames.tell());
SymNames << Name << '\0';
More information about the llvm-commits
mailing list