[clang-tools-extra] [modularize] Avoid repeated hash lookups (NFC) (PR #109508)
Nikita Popov via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 21 01:18:51 PDT 2024
================
@@ -508,13 +508,11 @@ class EntityMap : public std::map<std::string, SmallVector<Entry, 2>> {
// Sort contents.
llvm::sort(H->second);
- // Check whether we've seen this header before.
- auto KnownH = AllHeaderContents.find(H->first);
- if (KnownH == AllHeaderContents.end()) {
- // We haven't seen this header before; record its contents.
- AllHeaderContents.insert(*H);
+ // Record this header and its contents if we haven't seen it before.
+ auto [KnownH, Inserted] =
+ AllHeaderContents.try_emplace(H->first, H->second);
----------------
nikic wrote:
```suggestion
AllHeaderContents.insert(*H);
```
Maybe?
https://github.com/llvm/llvm-project/pull/109508
More information about the cfe-commits
mailing list