[clang] d1427fb - [Edit] Use StringRef::consume_back (NFC)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 28 10:47:13 PST 2024


Author: Kazu Hirata
Date: 2024-01-28T10:47:03-08:00
New Revision: d1427fb6d0e1dbe3b7dbf46c26e43ce96b9b56d5

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

LOG: [Edit] Use StringRef::consume_back (NFC)

Added: 
    

Modified: 
    clang/lib/Edit/RewriteObjCFoundationAPI.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp b/clang/lib/Edit/RewriteObjCFoundationAPI.cpp
index d5bf553e241240d..2e123e89b00365a 100644
--- a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp
+++ b/clang/lib/Edit/RewriteObjCFoundationAPI.cpp
@@ -697,11 +697,7 @@ static bool getLiteralInfo(SourceRange literalRange,
 
   struct Suff {
     static bool has(StringRef suff, StringRef &text) {
-      if (text.ends_with(suff)) {
-        text = text.substr(0, text.size()-suff.size());
-        return true;
-      }
-      return false;
+      return text.consume_back(suff);
     }
   };
 


        


More information about the cfe-commits mailing list