[llvm] 8926af4 - [Support] Use StringRef::starts_with (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 3 09:36:55 PST 2024
Author: Kazu Hirata
Date: 2024-02-03T09:36:45-08:00
New Revision: 8926af426f202c158dd17b2034c044e85eceb108
URL: https://github.com/llvm/llvm-project/commit/8926af426f202c158dd17b2034c044e85eceb108
DIFF: https://github.com/llvm/llvm-project/commit/8926af426f202c158dd17b2034c044e85eceb108.diff
LOG: [Support] Use StringRef::starts_with (NFC)
Added:
Modified:
llvm/lib/Support/VirtualFileSystem.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp
index c341170688037..051dd2a67d120 100644
--- a/llvm/lib/Support/VirtualFileSystem.cpp
+++ b/llvm/lib/Support/VirtualFileSystem.cpp
@@ -2782,10 +2782,9 @@ void JSONWriter::write(ArrayRef<YAMLVFSEntry> Entries,
StringRef RPath = Entry.RPath;
if (UseOverlayRelative) {
- unsigned OverlayDirLen = OverlayDir.size();
- assert(RPath.substr(0, OverlayDirLen) == OverlayDir &&
+ assert(RPath.starts_with(OverlayDir) &&
"Overlay dir must be contained in RPath");
- RPath = RPath.slice(OverlayDirLen, RPath.size());
+ RPath = RPath.slice(OverlayDir.size(), RPath.size());
}
bool IsCurrentDirEmpty = true;
@@ -2816,10 +2815,9 @@ void JSONWriter::write(ArrayRef<YAMLVFSEntry> Entries,
}
StringRef RPath = Entry.RPath;
if (UseOverlayRelative) {
- unsigned OverlayDirLen = OverlayDir.size();
- assert(RPath.substr(0, OverlayDirLen) == OverlayDir &&
+ assert(RPath.starts_with(OverlayDir) &&
"Overlay dir must be contained in RPath");
- RPath = RPath.slice(OverlayDirLen, RPath.size());
+ RPath = RPath.slice(OverlayDir.size(), RPath.size());
}
if (!Entry.IsDirectory) {
writeEntry(path::filename(Entry.VPath), RPath);
More information about the llvm-commits
mailing list