[clang-tools-extra] [clang-tidy] Avoid repeated hash lookups (NFC) (PR #127444)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 16 22:16:39 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tools-extra
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/127444.diff
1 Files Affected:
- (modified) clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp (+4-4)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/127444
More information about the cfe-commits
mailing list