aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/VirtualFileSystem.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-02-03 09:36:45 -0800
committerKazu Hirata <kazu@google.com>2024-02-03 09:36:45 -0800
commit8926af426f202c158dd17b2034c044e85eceb108 (patch)
tree763323b4d07efe1b07a2cd3e5b1eb7a4ace0b17f /llvm/lib/Support/VirtualFileSystem.cpp
parentab9a69878c7a14b85389c16e130ea117ee4f4358 (diff)
downloadllvm-8926af426f202c158dd17b2034c044e85eceb108.zip
llvm-8926af426f202c158dd17b2034c044e85eceb108.tar.gz
llvm-8926af426f202c158dd17b2034c044e85eceb108.tar.bz2
[Support] Use StringRef::starts_with (NFC)
Diffstat (limited to 'llvm/lib/Support/VirtualFileSystem.cpp')
-rw-r--r--llvm/lib/Support/VirtualFileSystem.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp
index c341170..051dd2a 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);