From: Peter Collingbourne Date: Tue, 10 Oct 2017 22:19:46 +0000 (+0000) Subject: Support: Have directory_iterator::status() return FindFirstFileEx/FindNextFile result... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2e86b2ecf1cfba047a8ccebf5a4499abe58dccb2;p=clang Support: Have directory_iterator::status() return FindFirstFileEx/FindNextFile results on Windows. This allows clients to avoid an unnecessary fs::status() call on each directory entry. Because the information returned by FindFirstFileEx is a subset of the information returned by a regular status() call, I needed to extract a base class from file_status that contains only that information. On my machine, this reduces the time required to enumerate a ThinLTO cache directory containing 520k files from almost 4 minutes to less than 2 seconds. Differential Revision: https://reviews.llvm.org/D38716 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315378 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/VirtualFileSystem.cpp b/lib/Basic/VirtualFileSystem.cpp index 47c7fa4ba7..debe5d9ad6 100644 --- a/lib/Basic/VirtualFileSystem.cpp +++ b/lib/Basic/VirtualFileSystem.cpp @@ -244,7 +244,7 @@ public: RealFSDirIter(const Twine &Path, std::error_code &EC) : Iter(Path, EC) { if (!EC && Iter != llvm::sys::fs::directory_iterator()) { llvm::sys::fs::file_status S; - EC = Iter->status(S); + EC = llvm::sys::fs::status(Iter->path(), S, true); CurrentEntry = Status::copyWithNewName(S, Iter->path()); } } @@ -258,7 +258,7 @@ public: CurrentEntry = Status(); } else { llvm::sys::fs::file_status S; - EC = Iter->status(S); + EC = llvm::sys::fs::status(Iter->path(), S, true); CurrentEntry = Status::copyWithNewName(S, Iter->path()); } return EC;