[clang] [AST] Avoid repeated hash lookups (NFC) (PR #130887)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 11 21:25:09 PDT 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/130887

None

>From b44c59388bfcb1fbf9c43ea37a844a678ee5652c Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 11 Mar 2025 09:39:04 -0700
Subject: [PATCH] [AST] Avoid repeated hash lookups (NFC)

---
 clang/lib/AST/ASTContext.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 55022a4bc000a..7ed5b033d9bd8 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -11832,8 +11832,8 @@ bool ASTContext::mergeExtParameterInfo(
 }
 
 void ASTContext::ResetObjCLayout(const ObjCInterfaceDecl *D) {
-  if (ObjCLayouts.count(D)) {
-    ObjCLayouts[D] = nullptr;
+  if (auto It = ObjCLayouts.find(D); It != ObjCLayouts.end()) {
+    It->second = nullptr;
     for (auto *SubClass : ObjCSubClasses[D])
       ResetObjCLayout(SubClass);
   }



More information about the cfe-commits mailing list