[RISCV] Use StringRef(&C, 1) instead of std::string(1, C).
authorCraig Topper <craig.topper@sifive.com>
Thu, 30 Mar 2023 04:37:26 +0000 (21:37 -0700)
committerCraig Topper <craig.topper@sifive.com>
Thu, 30 Mar 2023 04:51:24 +0000 (21:51 -0700)
We're calling functions that take a StringRef. We can create one
from a single character variable without using std::string.

llvm/lib/Support/RISCVISAInfo.cpp

index f4e0c04..96dee40 100644 (file)
@@ -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