https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/109508
None >From d50b829fd1277736b7e65886879fcfe9a45714f2 Mon Sep 17 00:00:00 2001 From: Kazu Hirata <k...@google.com> Date: Fri, 20 Sep 2024 13:31:12 -0700 Subject: [PATCH] [modularize] Avoid repeated hash lookups (NFC) --- clang-tools-extra/modularize/Modularize.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/clang-tools-extra/modularize/Modularize.cpp b/clang-tools-extra/modularize/Modularize.cpp index f3e7dfc20b027d..92e4792526d6f3 100644 --- a/clang-tools-extra/modularize/Modularize.cpp +++ b/clang-tools-extra/modularize/Modularize.cpp @@ -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); + if (Inserted) continue; - } // If the header contents are the same, we're done. if (H->second == KnownH->second) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits