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> { // 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)