[clang] [InstallAPI] Call DenseMap::find without constructing std::string (NFC) (PR #115260)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 6 20:22:14 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
KnownIncludes is of DenseMap<StringRef, HeaderType>, so we don't need
to allocate a temporary instance of std::string.
---
Full diff: https://github.com/llvm/llvm-project/pull/115260.diff
1 Files Affected:
- (modified) clang/lib/InstallAPI/Frontend.cpp (+1-1)
``````````diff
diff --git a/clang/lib/InstallAPI/Frontend.cpp b/clang/lib/InstallAPI/Frontend.cpp
index 2ebe72bf021cf9..9e8c60fbda3d00 100644
--- a/clang/lib/InstallAPI/Frontend.cpp
+++ b/clang/lib/InstallAPI/Frontend.cpp
@@ -94,7 +94,7 @@ InstallAPIContext::findAndRecordFile(const FileEntry *FE,
// included. This is primarily to resolve headers found
// in a different location than what passed directly as input.
StringRef IncludeName = PP.getHeaderSearchInfo().getIncludeNameForHeader(FE);
- auto BackupIt = KnownIncludes.find(IncludeName.str());
+ auto BackupIt = KnownIncludes.find(IncludeName);
if (BackupIt != KnownIncludes.end()) {
KnownFiles[FE] = BackupIt->second;
return BackupIt->second;
``````````
</details>
https://github.com/llvm/llvm-project/pull/115260
More information about the cfe-commits
mailing list