diff options
author | Douglas Gregor <dgregor@apple.com> | 2013-01-26 00:55:12 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2013-01-26 00:55:12 +0000 |
commit | 713b7c011869f177dc76e6df4f7f44b1bd073bb0 (patch) | |
tree | 2a5a5a69b2900acb1fdf5c3a3a6e9b7743baacc1 /include/clang/Basic/FileManager.h | |
parent | 25cf8abf30189323199b1424848b105940267c1b (diff) |
Since we're stuck with realpath for the header <-> module mapping,
factor the realpath calls into FileManager::getCanonicalName() so we
can cache the results of this epically slow operation. 5% speedup on
my modules test, and realpath drops out of the profile.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173542 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/FileManager.h')
-rw-r--r-- | include/clang/Basic/FileManager.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h index 5914e1608f..6d9e53b7eb 100644 --- a/include/clang/Basic/FileManager.h +++ b/include/clang/Basic/FileManager.h @@ -17,6 +17,7 @@ #include "clang/Basic/FileSystemOptions.h" #include "clang/Basic/LLVM.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallVector.h" @@ -152,6 +153,12 @@ class FileManager : public RefCountedBase<FileManager> { /// \see SeenDirEntries llvm::StringMap<FileEntry*, llvm::BumpPtrAllocator> SeenFileEntries; + /// \brief The canonical names of directories. + llvm::DenseMap<const DirectoryEntry *, llvm::StringRef> CanonicalDirNames; + + /// \brief Storage for canonical names that we have computed. + llvm::BumpPtrAllocator CanonicalNameStorage; + /// \brief Each FileEntry we create is assigned a unique ID #. /// unsigned NextFileUID; @@ -257,6 +264,13 @@ public: static void modifyFileEntry(FileEntry *File, off_t Size, time_t ModificationTime); + /// \brief Retrieve the canonical name for a given directory. + /// + /// This is a very expensive operation, despite its results being cached, + /// and should only be used when the physical layout of the file system is + /// required, which is (almost) never. + StringRef getCanonicalName(const DirectoryEntry *Dir); + void PrintStats() const; }; |