Skip to content

Commit 8d61f82

Browse files
authored
[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.
1 parent b2ea046 commit 8d61f82

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lld/ELF/Arch/RISCV.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,12 +1074,12 @@ static void mergeArch(RISCVISAInfo::OrderedExtensionMap &mergedExts,
10741074
mergedXlen = info.getXLen();
10751075
} else {
10761076
for (const auto &ext : info.getExtensions()) {
1077-
if (auto it = mergedExts.find(ext.first); it != mergedExts.end()) {
1078-
if (std::tie(it->second.Major, it->second.Minor) >=
1077+
auto p = mergedExts.insert(ext);
1078+
if (!p.second) {
1079+
if (std::tie(p.first->second.Major, p.first->second.Minor) <
10791080
std::tie(ext.second.Major, ext.second.Minor))
1080-
continue;
1081+
p.first->second = ext.second;
10811082
}
1082-
mergedExts[ext.first] = ext.second;
10831083
}
10841084
}
10851085
}

0 commit comments

Comments
 (0)