[clang] [libclang] Avoid repeated hash lookups (NFC) (PR #111087)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 3 19:57:31 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/111087
None
>From df0ae6125e18bae6e90863300e12d094654b7b1f Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 3 Oct 2024 08:45:56 -0700
Subject: [PATCH] [libclang] Avoid repeated hash lookups (NFC)
---
clang/tools/libclang/CXIndexDataConsumer.cpp | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
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