Skip to content

Commit ec60030

Browse files
[DWARFLinker] Avoid repeated hash lookups (NFC) (#109904)
1 parent ba3d174 commit ec60030

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

llvm/include/llvm/DWARFLinker/IndexedValuesMap.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ namespace dwarf_linker {
2121
template <typename T> class IndexedValuesMap {
2222
public:
2323
uint64_t getValueIndex(T Value) {
24-
typename ValueToIndexMapTy::iterator It = ValueToIndexMap.find(Value);
25-
if (It == ValueToIndexMap.end()) {
26-
It = ValueToIndexMap.insert(std::make_pair(Value, Values.size())).first;
24+
auto [It, Inserted] = ValueToIndexMap.try_emplace(Value, Values.size());
25+
if (Inserted)
2726
Values.push_back(Value);
28-
}
2927
return It->second;
3028
}
3129

0 commit comments

Comments
 (0)