From 8926af426f202c158dd17b2034c044e85eceb108 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 3 Feb 2024 09:36:45 -0800 Subject: [Support] Use StringRef::starts_with (NFC) --- llvm/lib/Support/VirtualFileSystem.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'llvm/lib/Support/VirtualFileSystem.cpp') diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp index c34117068803..051dd2a67d12 100644 --- a/llvm/lib/Support/VirtualFileSystem.cpp +++ b/llvm/lib/Support/VirtualFileSystem.cpp @@ -2782,10 +2782,9 @@ void JSONWriter::write(ArrayRef 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 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); -- cgit v1.2.3