Skip to content

[DebugInfo] Avoid creating a temporary instance of std::string (NFC) #142523

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

Conversation

kazutakahirata
Copy link
Contributor

lookupTarget accepts StringRef. We don't need to create a temporary
instance of std::string only to be converted back to StringRef.

lookupTarget accepts StringRef.  We don't need to create a temporary
instance of std::string only to be converted back to StringRef.
@llvmbot
Copy link
Member

llvmbot commented Jun 3, 2025

@llvm/pr-subscribers-debuginfo

Author: Kazu Hirata (kazutakahirata)

Changes

lookupTarget accepts StringRef. We don't need to create a temporary
instance of std::string only to be converted back to StringRef.


Full diff: https://github.com/llvm/llvm-project/pull/142523.diff

1 Files Affected:

  • (modified) llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp (+1-1)
diff --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
index 434709f076dc5..ed1d5e46f00a8 100644
--- a/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
@@ -278,7 +278,7 @@ Error LVBinaryReader::loadGenericTargetInfo(StringRef TheTriple,
                                             StringRef TheFeatures) {
   std::string TargetLookupError;
   const Target *TheTarget =
-      TargetRegistry::lookupTarget(std::string(TheTriple), TargetLookupError);
+      TargetRegistry::lookupTarget(TheTriple, TargetLookupError);
   if (!TheTarget)
     return createStringError(errc::invalid_argument, TargetLookupError.c_str());
 

@kazutakahirata kazutakahirata merged commit d77c995 into llvm:main Jun 3, 2025
13 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250603_std_string_roundtrip_llvm_Debug branch June 3, 2025 06:27
sallto pushed a commit to sallto/llvm-project that referenced this pull request Jun 3, 2025
…lvm#142523)

lookupTarget accepts StringRef.  We don't need to create a temporary
instance of std::string only to be converted back to StringRef.
rorth pushed a commit to rorth/llvm-project that referenced this pull request Jun 11, 2025
…lvm#142523)

lookupTarget accepts StringRef.  We don't need to create a temporary
instance of std::string only to be converted back to StringRef.
DhruvSrivastavaX pushed a commit to DhruvSrivastavaX/lldb-for-aix that referenced this pull request Jun 12, 2025
…lvm#142523)

lookupTarget accepts StringRef.  We don't need to create a temporary
instance of std::string only to be converted back to StringRef.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants