Skip to content

Commit bdb6f1b

Browse files
[APINotes] Avoid repeated hash lookups (NFC) (#107758)
1 parent 668cbd8 commit bdb6f1b

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

clang/lib/APINotes/APINotesWriter.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,8 @@ class APINotesWriter::Implementation {
147147
for (auto piece : SelectorRef.Identifiers)
148148
Selector.Identifiers.push_back(getIdentifier(piece));
149149

150-
// Look for the stored selector.
151-
auto Known = SelectorIDs.find(Selector);
152-
if (Known != SelectorIDs.end())
153-
return Known->second;
154-
155-
// Add to the selector table.
156-
Known = SelectorIDs.insert({Selector, SelectorIDs.size()}).first;
157-
return Known->second;
150+
// Look for the stored selector. Add to the selector table if missing.
151+
return SelectorIDs.try_emplace(Selector, SelectorIDs.size()).first->second;
158152
}
159153

160154
private:

0 commit comments

Comments
 (0)