[llvm] 4d26690 - [YAML] Simplify code a bit. NFC.

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 5 13:27:32 PST 2022


Author: Benjamin Kramer
Date: 2022-03-05T22:24:35+01:00
New Revision: 4d2669002e0f0b5830d4ae51541297f66d50bf45

URL: https://github.com/llvm/llvm-project/commit/4d2669002e0f0b5830d4ae51541297f66d50bf45
DIFF: https://github.com/llvm/llvm-project/commit/4d2669002e0f0b5830d4ae51541297f66d50bf45.diff

LOG: [YAML] Simplify code a bit. NFC.

Added: 
    

Modified: 
    llvm/include/llvm/Support/YAMLTraits.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/YAMLTraits.h b/llvm/include/llvm/Support/YAMLTraits.h
index 7ad73543fc6e0..db462ea45dffb 100644
--- a/llvm/include/llvm/Support/YAMLTraits.h
+++ b/llvm/include/llvm/Support/YAMLTraits.h
@@ -537,9 +537,8 @@ template <class T> struct has_PolymorphicTraits {
 };
 
 inline bool isNumeric(StringRef S) {
-  const static auto skipDigits = [](StringRef Input) {
-    return Input.drop_front(
-        std::min(Input.find_first_not_of("0123456789"), Input.size()));
+  const auto skipDigits = [](StringRef Input) {
+    return Input.ltrim("0123456789");
   };
 
   // Make S.front() and S.drop_front().front() (if S.front() is [+-]) calls
@@ -666,8 +665,7 @@ inline QuotingType needsQuotes(StringRef S) {
   // 7.3.3 Plain Style
   // Plain scalars must not begin with most indicators, as this would cause
   // ambiguity with other YAML constructs.
-  static constexpr char Indicators[] = R"(-?:\,[]{}#&*!|>'"%@`)";
-  if (S.find_first_of(Indicators) == 0)
+  if (std::strchr(R"(-?:\,[]{}#&*!|>'"%@`)", S[0]) != nullptr)
     MaxQuotingNeeded = QuotingType::Single;
 
   for (unsigned char C : S) {


        


More information about the llvm-commits mailing list