Skip to content

[InstallAPI] Call DenseMap::find without constructing std::string (NFC) #115260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

kazutakahirata
Copy link
Contributor

KnownIncludes is of DenseMap<StringRef, HeaderType>, so we don't need
to allocate a temporary instance of std::string.

KnownIncludes is of DenseMap<StringRef, HeaderType>, so we don't need
to allocate a temporary instance of std::string.
@kazutakahirata kazutakahirata requested review from nikic and removed request for cyndyishida November 7, 2024 04:21
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Nov 7, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 7, 2024

@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)

Changes

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 --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;

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@kazutakahirata kazutakahirata merged commit c714f92 into llvm:main Nov 7, 2024
10 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_heterogenous_InstallAPI branch November 7, 2024 18:54
Groverkss pushed a commit to iree-org/llvm-project that referenced this pull request Nov 15, 2024
…C) (llvm#115260)

KnownIncludes is of DenseMap<StringRef, HeaderType>, so we don't need
to allocate a temporary instance of std::string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants