[clang-tools-extra] ff4e21f - [clang-tidy] Avoid repeated hash lookups (NFC) (#127444)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 17 01:31:56 PST 2025
Author: Kazu Hirata
Date: 2025-02-17T01:31:52-08:00
New Revision: ff4e21fccc439085f6381076a2ac7d9fa371ab29
URL: https://github.com/llvm/llvm-project/commit/ff4e21fccc439085f6381076a2ac7d9fa371ab29
DIFF: https://github.com/llvm/llvm-project/commit/ff4e21fccc439085f6381076a2ac7d9fa371ab29.diff
LOG: [clang-tidy] Avoid repeated hash lookups (NFC) (#127444)
Added:
Modified:
clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
index 6a467910521f5..3d3a79d8eaf21 100644
--- a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
@@ -199,10 +199,10 @@ void IncludeModernizePPCallbacks::InclusionDirective(
// 2. Insert `using namespace std;` to the beginning of TU.
// 3. Do nothing and let the user deal with the migration himself.
SourceLocation DiagLoc = FilenameRange.getBegin();
- if (CStyledHeaderToCxx.count(FileName) != 0) {
- IncludesToBeProcessed.emplace_back(
- IncludeMarker{CStyledHeaderToCxx[FileName], FileName,
- FilenameRange.getAsRange(), DiagLoc});
+ if (auto It = CStyledHeaderToCxx.find(FileName);
+ It != CStyledHeaderToCxx.end()) {
+ IncludesToBeProcessed.emplace_back(IncludeMarker{
+ It->second, FileName, FilenameRange.getAsRange(), DiagLoc});
} else if (DeleteHeaders.count(FileName) != 0) {
IncludesToBeProcessed.emplace_back(
// NOLINTNEXTLINE(modernize-use-emplace) - false-positive
More information about the cfe-commits
mailing list