[llvm] e4044a7 - [ADT] StringSwitch.h - use StringRef::starts_with/ends_with instead of startswith/endswith. NFC.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 6 07:52:32 PST 2023


Author: Simon Pilgrim
Date: 2023-11-06T15:52:18Z
New Revision: e4044a724c648ef2d8b8f866d5013c84cadc5d6b

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

LOG: [ADT] StringSwitch.h - use StringRef::starts_with/ends_with instead of startswith/endswith. NFC.

startswith/endswith wrap starts_with/ends_with and will eventually go away (to more closely match string_view)

Added: 
    

Modified: 
    llvm/include/llvm/ADT/StringSwitch.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/StringSwitch.h b/llvm/include/llvm/ADT/StringSwitch.h
index 519f7c4f2125a79..7093da07663a0c8 100644
--- a/llvm/include/llvm/ADT/StringSwitch.h
+++ b/llvm/include/llvm/ADT/StringSwitch.h
@@ -74,14 +74,14 @@ class StringSwitch {
   }
 
   StringSwitch& EndsWith(StringLiteral S, T Value) {
-    if (!Result && Str.endswith(S)) {
+    if (!Result && Str.ends_with(S)) {
       Result = std::move(Value);
     }
     return *this;
   }
 
   StringSwitch& StartsWith(StringLiteral S, T Value) {
-    if (!Result && Str.startswith(S)) {
+    if (!Result && Str.starts_with(S)) {
       Result = std::move(Value);
     }
     return *this;


        


More information about the llvm-commits mailing list