[clang-tools-extra] [clang-tidy] Avoid repeated map lookups (NFC) (PR #132656)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 23 19:56:34 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tidy
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/132656.diff
1 Files Affected:
- (modified) clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp (+3-4)
``````````diff
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.
``````````
</details>
https://github.com/llvm/llvm-project/pull/132656
More information about the cfe-commits
mailing list