From f66803457ec7f88fa86376d9aef677dea107818c Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Thu, 16 Dec 2021 09:27:12 +0100 Subject: [clang][deps] Squash caches for original and minimized files The minimizing and caching filesystem used by the dependency scanner keeps minimized and original files in separate caches. This setup is not well suited for dealing with files that are sometimes minimized and sometimes not. Such files are being stat-ed and read twice, which is wasteful and also means the two versions of the file can get "out of sync". This patch squashes the two caches together. When a file is stat-ed or read, its original contents are populated. If a file needs to be minimized, we give the minimizer the already loaded contents instead of reading the file again. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D115346 --- llvm/lib/Support/VirtualFileSystem.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'llvm/lib/Support/VirtualFileSystem.cpp') diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp index 9bf0384..bec4e8d 100644 --- a/llvm/lib/Support/VirtualFileSystem.cpp +++ b/llvm/lib/Support/VirtualFileSystem.cpp @@ -75,6 +75,12 @@ Status::Status(const Twine &Name, UniqueID UID, sys::TimePoint<> MTime, : Name(Name.str()), UID(UID), MTime(MTime), User(User), Group(Group), Size(Size), Type(Type), Perms(Perms) {} +Status Status::copyWithNewSize(const Status &In, uint64_t NewSize) { + return Status(In.getName(), In.getUniqueID(), In.getLastModificationTime(), + In.getUser(), In.getGroup(), NewSize, In.getType(), + In.getPermissions()); +} + Status Status::copyWithNewName(const Status &In, const Twine &NewName) { return Status(NewName, In.getUniqueID(), In.getLastModificationTime(), In.getUser(), In.getGroup(), In.getSize(), In.getType(), -- cgit v1.1