[llvm] e2630a5 - [RISCV] Use StringRef(&C, 1) instead of std::string(1, C).
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 29 21:52:27 PDT 2023
Author: Craig Topper
Date: 2023-03-29T21:51:24-07:00
New Revision: e2630a5b4cd2dd50eec9478cb7a18395b98df238
URL: https://github.com/llvm/llvm-project/commit/e2630a5b4cd2dd50eec9478cb7a18395b98df238
DIFF: https://github.com/llvm/llvm-project/commit/e2630a5b4cd2dd50eec9478cb7a18395b98df238.diff
LOG: [RISCV] Use StringRef(&C, 1) instead of std::string(1, C).
We're calling functions that take a StringRef. We can create one
from a single character variable without using std::string.
Added:
Modified:
llvm/lib/Support/RISCVISAInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp
index f4e0c04152b5a..96dee400643a6 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -660,19 +660,19 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
} else {
// Baseline is `i` or `e`
if (auto E = getExtensionVersion(
- std::string(1, Baseline), Exts, Major, Minor, ConsumeLength,
+ StringRef(&Baseline, 1), Exts, Major, Minor, ConsumeLength,
EnableExperimentalExtension, ExperimentalExtensionVersionCheck)) {
if (!IgnoreUnknown)
return std::move(E);
// If IgnoreUnknown, then ignore an unrecognised version of the baseline
// ISA and just use the default supported version.
consumeError(std::move(E));
- auto Version = findDefaultVersion(std::string(1, Baseline));
+ auto Version = findDefaultVersion(StringRef(&Baseline, 1));
Major = Version->Major;
Minor = Version->Minor;
}
- ISAInfo->addExtension(std::string(1, Baseline), Major, Minor);
+ ISAInfo->addExtension(StringRef(&Baseline, 1), Major, Minor);
}
// Consume the base ISA version number and any '_' between rvxxx and the
@@ -717,7 +717,7 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
unsigned Major, Minor, ConsumeLength;
if (std::next(I) != E)
Next = std::string(std::next(I), E);
- if (auto E = getExtensionVersion(std::string(1, C), Next, Major, Minor,
+ if (auto E = getExtensionVersion(StringRef(&C, 1), Next, Major, Minor,
ConsumeLength, EnableExperimentalExtension,
ExperimentalExtensionVersionCheck)) {
if (IgnoreUnknown) {
@@ -740,7 +740,7 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
"unsupported standard user-level extension '%c'",
C);
}
- ISAInfo->addExtension(std::string(1, C), Major, Minor);
+ ISAInfo->addExtension(StringRef(&C, 1), Major, Minor);
// Consume full extension name and version, including any optional '_'
// between this extension and the next
More information about the llvm-commits
mailing list