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

None

>From efa4f020eda6ff2f9da14f250be72fb6bc17b59c Mon Sep 17 00:00:00 2001
From: Kazu Hirata <k...@google.com>
Date: Sun, 23 Mar 2025 08:06:57 -0700
Subject: [PATCH] [clang-tidy] Avoid repeated map lookups (NFC)

---
 clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp 
b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
index afe70dc8e6d5b..f574c94e6f144 100644
--- a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
+++ b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
@@ -88,11 +88,10 @@ class HeaderGuardPPCallbacks : public PPCallbacks {
         continue;
 
       // Look up Locations for this guard.
-      SourceLocation Ifndef =
-          Ifndefs[MacroEntry.first.getIdentifierInfo()].second;
+      const auto &Locs = Ifndefs[MacroEntry.first.getIdentifierInfo()];
+      SourceLocation Ifndef = Locs.second;
       SourceLocation Define = MacroEntry.first.getLocation();
-      SourceLocation EndIf =
-          EndIfs[Ifndefs[MacroEntry.first.getIdentifierInfo()].first];
+      SourceLocation EndIf = EndIfs[Locs.first];
 
       // If the macro Name is not equal to what we can compute, correct it in
       // the #ifndef and #define.

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to