[clang-tools-extra] da38e1d - [modularize] Avoid repeated hash lookups (NFC) (#109508)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 21 14:01:19 PDT 2024
Author: Kazu Hirata
Date: 2024-09-21T14:01:16-07:00
New Revision: da38e1d5a962b45fd95034fc0a00f26526ec3c70
URL: https://github.com/llvm/llvm-project/commit/da38e1d5a962b45fd95034fc0a00f26526ec3c70
DIFF: https://github.com/llvm/llvm-project/commit/da38e1d5a962b45fd95034fc0a00f26526ec3c70.diff
LOG: [modularize] Avoid repeated hash lookups (NFC) (#109508)
Co-authored-by: Nikita Popov <github at npopov.com>
Added:
Modified:
clang-tools-extra/modularize/Modularize.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/modularize/Modularize.cpp b/clang-tools-extra/modularize/Modularize.cpp
index f3e7dfc20b027d..2c00c76c855336 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -508,13 +508,10 @@ 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.insert(*H);
+ if (Inserted)
continue;
- }
// If the header contents are the same, we're done.
if (H->second == KnownH->second)
More information about the cfe-commits
mailing list