[llvm] 3bf9e63 - [lli] Use StringRef::consume_front (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 29 18:46:22 PST 2024


Author: Kazu Hirata
Date: 2024-01-29T18:46:09-08:00
New Revision: 3bf9e63e705f580917e89259e71469a81679bab5

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

LOG: [lli] Use StringRef::consume_front (NFC)

Added: 
    

Modified: 
    llvm/tools/lli/lli.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
index 905ec23de45b9..25f43a4bb6811 100644
--- a/llvm/tools/lli/lli.cpp
+++ b/llvm/tools/lli/lli.cpp
@@ -347,13 +347,11 @@ class LLIObjectCache : public ObjectCache {
 private:
   std::string CacheDir;
 
-  bool getCacheFilename(const std::string &ModID, std::string &CacheName) {
-    std::string Prefix("file:");
-    size_t PrefixLength = Prefix.length();
-    if (ModID.substr(0, PrefixLength) != Prefix)
+  bool getCacheFilename(StringRef ModID, std::string &CacheName) {
+    if (!ModID.consume_front("file:"))
       return false;
 
-    std::string CacheSubdir = ModID.substr(PrefixLength);
+    std::string CacheSubdir = std::string(ModID);
     // Transform "X:\foo" => "/X\foo" for convenience on Windows.
     if (is_style_windows(llvm::sys::path::Style::native) &&
         isalpha(CacheSubdir[0]) && CacheSubdir[1] == ':') {


        


More information about the llvm-commits mailing list