Skip to content

Commit 9a99e55

Browse files
[gold-plugin] Avoid repeated hash lookups (NFC) (#109748)
1 parent 96eff99 commit 9a99e55

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

llvm/tools/gold/gold-plugin.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,9 +1057,11 @@ static std::vector<std::pair<SmallString<128>, bool>> runLTO() {
10571057
getThinLTOOldAndNewSuffix(OldSuffix, NewSuffix);
10581058

10591059
for (claimed_file &F : Modules) {
1060-
if (options::thinlto && !HandleToInputFile.count(F.leader_handle))
1061-
HandleToInputFile.insert(std::make_pair(
1062-
F.leader_handle, std::make_unique<PluginInputFile>(F.handle)));
1060+
if (options::thinlto) {
1061+
auto [It, Inserted] = HandleToInputFile.try_emplace(F.leader_handle);
1062+
if (Inserted)
1063+
It->second = std::make_unique<PluginInputFile>(F.handle);
1064+
}
10631065
// In case we are thin linking with a minimized bitcode file, ensure
10641066
// the module paths encoded in the index reflect where the backends
10651067
// will locate the full bitcode files for compiling/importing.

0 commit comments

Comments
 (0)