[clang] 08085ed - [CodeGen] Avoid repeated hash lookups (NFC) (#107759)

via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 8 09:04:24 PDT 2024


Author: Kazu Hirata
Date: 2024-09-08T09:04:20-07:00
New Revision: 08085eddfdca51f2bcc23945579109d01b730310

URL: https://github.com/llvm/llvm-project/commit/08085eddfdca51f2bcc23945579109d01b730310
DIFF: https://github.com/llvm/llvm-project/commit/08085eddfdca51f2bcc23945579109d01b730310.diff

LOG: [CodeGen] Avoid repeated hash lookups (NFC) (#107759)

Added: 
    

Modified: 
    clang/lib/CodeGen/CoverageMappingGen.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 67a9caf8b4ec4b..07015834bc84f3 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -2595,12 +2595,7 @@ void CoverageMappingModuleGen::emit() {
 }
 
 unsigned CoverageMappingModuleGen::getFileID(FileEntryRef File) {
-  auto It = FileEntries.find(File);
-  if (It != FileEntries.end())
-    return It->second;
-  unsigned FileID = FileEntries.size() + 1;
-  FileEntries.insert(std::make_pair(File, FileID));
-  return FileID;
+  return FileEntries.try_emplace(File, FileEntries.size() + 1).first->second;
 }
 
 void CoverageMappingGen::emitCounterMapping(const Decl *D,


        


More information about the cfe-commits mailing list