Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Sep 27, 2024

@llvm/pr-subscribers-llvm-binary-utilities

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/110201.diff

1 Files Affected:

  • (modified) llvm/lib/Object/ArchiveWriter.cpp (+1-2)
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';

@kazutakahirata kazutakahirata force-pushed the cleanup_001_repeated_hash_ArchiveWriter branch 2 times, most recently from 56da9b5 to 2bbfda7 Compare September 28, 2024 00:19
@kazutakahirata kazutakahirata force-pushed the cleanup_001_repeated_hash_ArchiveWriter branch from 2bbfda7 to 8cb8b2b Compare September 28, 2024 08:21
@kazutakahirata kazutakahirata merged commit 60a6e6f into llvm:main Sep 28, 2024
4 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_ArchiveWriter branch September 28, 2024 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants