[llvm] 0b96d22 - [SPIRV] Use StringRef instead of std::string (NFC) (#138408)
via llvm-commits
llvm-commits at lists.llvm.org
Sat May 3 10:12:51 PDT 2025
Author: Kazu Hirata
Date: 2025-05-03T10:12:47-07:00
New Revision: 0b96d22f95eeef00ec40723f0d59ccb4389dc1b6
URL: https://github.com/llvm/llvm-project/commit/0b96d22f95eeef00ec40723f0d59ccb4389dc1b6
DIFF: https://github.com/llvm/llvm-project/commit/0b96d22f95eeef00ec40723f0d59ccb4389dc1b6.diff
LOG: [SPIRV] Use StringRef instead of std::string (NFC) (#138408)
We can use StringRef for PassPrefix because it is used only with
StringRef::starts_with.
Added:
Modified:
llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp b/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
index 78c0d252cb834..c516be0297e66 100644
--- a/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
@@ -184,11 +184,11 @@ namespace SPIRV {
/// Parses the name part of the demangled builtin call.
std::string lookupBuiltinNameHelper(StringRef DemangledCall,
FPDecorationId *DecorationId) {
- const static std::string PassPrefix = "(anonymous namespace)::";
+ StringRef PassPrefix = "(anonymous namespace)::";
std::string BuiltinName;
// Itanium Demangler result may have "(anonymous namespace)::" prefix
- if (DemangledCall.starts_with(PassPrefix.c_str()))
- BuiltinName = DemangledCall.substr(PassPrefix.length());
+ if (DemangledCall.starts_with(PassPrefix))
+ BuiltinName = DemangledCall.substr(PassPrefix.size());
else
BuiltinName = DemangledCall;
// Extract the builtin function name and types of arguments from the call
More information about the llvm-commits
mailing list