From: Argyrios Kyrtzidis Date: Mon, 4 Mar 2013 20:33:40 +0000 (+0000) Subject: [PCH] In HeaderFileInfoTrait::EqualKey(), use FileManager::getFile() to compare two... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1c1508b37bc2a9419b2e22beef9e788eb74203f4;p=clang [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 297b577eee..2744865819 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -1135,6 +1135,7 @@ public: ~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 e6ef9f6441..4a4f2aaf91 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -1309,11 +1309,10 @@ bool HeaderFileInfoTrait::EqualKey(internal_key_type a, internal_key_type b) { 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