[lld][RISCV] Avoid second map lookup in mergeArch. NFC (#84687)
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.
GitOrigin-RevId: 8d61f82bd3676bc541edfad1014e3ed599cc1390
diff --git a/ELF/Arch/RISCV.cpp b/ELF/Arch/RISCV.cpp
index 4798c86..20de1b9 100644
--- a/ELF/Arch/RISCV.cpp
+++ b/ELF/Arch/RISCV.cpp
@@ -1074,12 +1074,12 @@
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;
}
}
}