Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@kazutakahirata kazutakahirata requested a review from nikic March 12, 2025 04:25
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Mar 12, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 12, 2025

@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/130887.diff

1 Files Affected:

  • (modified) clang/lib/AST/ASTContext.cpp (+2-2)
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);
   }

@kazutakahirata kazutakahirata merged commit e5aac52 into llvm:main Mar 12, 2025
14 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_clang_AST branch March 12, 2025 15:46
frederik-h pushed a commit to frederik-h/llvm-project that referenced this pull request Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants