aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/VirtualFileSystem.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-08-25 11:30:49 -0700
committerGitHub <noreply@github.com>2024-08-25 11:30:49 -0700
commit33e7cd6ff23f6c904314d17c68dc58168fd32d09 (patch)
tree544969f067771e290d1c729ab896219dc1da135e /llvm/lib/Support/VirtualFileSystem.cpp
parent33f3ebc86e7d3afcb65c551feba5bbc2421b42ed (diff)
downloadllvm-33e7cd6ff23f6c904314d17c68dc58168fd32d09.zip
llvm-33e7cd6ff23f6c904314d17c68dc58168fd32d09.tar.gz
llvm-33e7cd6ff23f6c904314d17c68dc58168fd32d09.tar.bz2
[llvm] Prefer StringRef::substr to StringRef::slice (NFC) (#105943)
S.substr(N) is simpler than S.slice(N, StringRef::npos) and S.slice(N, S.size()). Also, substr is probably better recognizable than slice thanks to std::string_view::substr.
Diffstat (limited to 'llvm/lib/Support/VirtualFileSystem.cpp')
-rw-r--r--llvm/lib/Support/VirtualFileSystem.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp
index 9d21eba..6d756f4 100644
--- a/llvm/lib/Support/VirtualFileSystem.cpp
+++ b/llvm/lib/Support/VirtualFileSystem.cpp
@@ -2780,7 +2780,7 @@ bool JSONWriter::containedIn(StringRef Parent, StringRef Path) {
StringRef JSONWriter::containedPart(StringRef Parent, StringRef Path) {
assert(!Parent.empty());
assert(containedIn(Parent, Path));
- return Path.slice(Parent.size() + 1, StringRef::npos);
+ return Path.substr(Parent.size() + 1);
}
void JSONWriter::startDirectory(StringRef Path) {
@@ -2846,7 +2846,7 @@ void JSONWriter::write(ArrayRef<YAMLVFSEntry> Entries,
if (UseOverlayRelative) {
assert(RPath.starts_with(OverlayDir) &&
"Overlay dir must be contained in RPath");
- RPath = RPath.slice(OverlayDir.size(), RPath.size());
+ RPath = RPath.substr(OverlayDir.size());
}
bool IsCurrentDirEmpty = true;
@@ -2879,7 +2879,7 @@ void JSONWriter::write(ArrayRef<YAMLVFSEntry> Entries,
if (UseOverlayRelative) {
assert(RPath.starts_with(OverlayDir) &&
"Overlay dir must be contained in RPath");
- RPath = RPath.slice(OverlayDir.size(), RPath.size());
+ RPath = RPath.substr(OverlayDir.size());
}
if (!Entry.IsDirectory) {
writeEntry(path::filename(Entry.VPath), RPath);