[clang] dada3c3 - [libclang] Avoid repeated hash lookups (NFC) (#111087)

via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 4 07:38:18 PDT 2024


Author: Kazu Hirata
Date: 2024-10-04T07:38:14-07:00
New Revision: dada3c316d69ab641c9972062745ac16af34533e

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

LOG: [libclang] Avoid repeated hash lookups (NFC) (#111087)

Added: 
    

Modified: 
    clang/tools/libclang/CXIndexDataConsumer.cpp

Removed: 
    


################################################################################
diff  --git a/clang/tools/libclang/CXIndexDataConsumer.cpp b/clang/tools/libclang/CXIndexDataConsumer.cpp
index 8d364ed8876a12..ced94e13baf12e 100644
--- a/clang/tools/libclang/CXIndexDataConsumer.cpp
+++ b/clang/tools/libclang/CXIndexDataConsumer.cpp
@@ -952,18 +952,12 @@ void CXIndexDataConsumer::addContainerInMap(const DeclContext *DC,
   if (!DC)
     return;
 
-  ContainerMapTy::iterator I = ContainerMap.find(DC);
-  if (I == ContainerMap.end()) {
-    if (container)
-      ContainerMap[DC] = container;
-    return;
-  }
   // Allow changing the container of a previously seen DeclContext so we
   // can handle invalid user code, like a function re-definition.
   if (container)
-    I->second = container;
+    ContainerMap[DC] = container;
   else
-    ContainerMap.erase(I);
+    ContainerMap.erase(DC);
 }
 
 CXIdxClientEntity CXIndexDataConsumer::getClientEntity(const Decl *D) const {


        


More information about the cfe-commits mailing list