[PCH] In HeaderFileInfoTrait::EqualKey(), use FileManager::getFile() to compare two filenames, instead of llvm::sys::fs::equivalent().
llvm::sys::fs::equivalent() does 2 stat calls every time it's called. Use FileManager::getFile() to take advantage
of the stat caching that FileManager is providing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176450 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h
index 297b577..2744865 100644
--- a/include/clang/Serialization/ASTReader.h
+++ b/include/clang/Serialization/ASTReader.h
@@ -1135,6 +1135,7 @@
~ASTReader();
SourceManager &getSourceManager() const { return SourceMgr; }
+ FileManager &getFileManager() const { return FileMgr; }
/// \brief Flags that indicate what kind of AST loading failures the client
/// of the AST reader can directly handle.
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index e6ef9f6..4a4f2aa 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -1309,11 +1309,10 @@
return false;
// Determine whether the actual files are equivalent.
- bool Result = false;
- if (llvm::sys::fs::equivalent(a, b, Result))
- return false;
-
- return Result;
+ FileManager &FileMgr = Reader.getFileManager();
+ const FileEntry *FEA = FileMgr.getFile(a);
+ const FileEntry *FEB = FileMgr.getFile(b);
+ return (FEA && FEA == FEB);
}
std::pair<unsigned, unsigned>