Skip to content

Commit

Permalink
[lld][RISCV] Avoid second map lookup in mergeArch. NFC (llvm#84687)
Browse files Browse the repository at this point in the history
Instead of using find and then inserting into the map, we can use
insert and fix up the version using the iterator if the insert fails.
  • Loading branch information
topperc authored Mar 12, 2024
1 parent b2ea046 commit 8d61f82
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lld/ELF/Arch/RISCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1074,12 +1074,12 @@ static void mergeArch(RISCVISAInfo::OrderedExtensionMap &mergedExts,
mergedXlen = info.getXLen();
} else {
for (const auto &ext : info.getExtensions()) {
if (auto it = mergedExts.find(ext.first); it != mergedExts.end()) {
if (std::tie(it->second.Major, it->second.Minor) >=
auto p = mergedExts.insert(ext);
if (!p.second) {
if (std::tie(p.first->second.Major, p.first->second.Minor) <
std::tie(ext.second.Major, ext.second.Minor))
continue;
p.first->second = ext.second;
}
mergedExts[ext.first] = ext.second;
}
}
}
Expand Down

0 comments on commit 8d61f82

Please sign in to comment.