r176450 - [PCH] In HeaderFileInfoTrait::EqualKey(), use FileManager::getFile() to compare two filenames, instead of llvm::sys::fs::equivalent().

Argyrios Kyrtzidis akyrtzi at gmail.com
Mon Mar 4 12:33:41 PST 2013


Author: akirtzidis
Date: Mon Mar  4 14:33:40 2013
New Revision: 176450

URL: http://llvm.org/viewvc/llvm-project?rev=176450&view=rev
Log:
[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.

Modified:
    cfe/trunk/include/clang/Serialization/ASTReader.h
    cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=176450&r1=176449&r2=176450&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Mon Mar  4 14:33:40 2013
@@ -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.

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=176450&r1=176449&r2=176450&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Mon Mar  4 14:33:40 2013
@@ -1309,11 +1309,10 @@ bool HeaderFileInfoTrait::EqualKey(inter
     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>





More information about the cfe-commits mailing list