]> granicus.if.org Git - clang/commitdiff
Support: Have directory_iterator::status() return FindFirstFileEx/FindNextFile result...
authorPeter Collingbourne <peter@pcc.me.uk>
Tue, 10 Oct 2017 22:19:46 +0000 (22:19 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Tue, 10 Oct 2017 22:19:46 +0000 (22:19 +0000)
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

lib/Basic/VirtualFileSystem.cpp

index 47c7fa4ba77f38ba630ed30568ecbfa55c44e87b..debe5d9ad615d9092deb86d10a14fdbaff3dcc34 100644 (file)
@@ -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;