]> granicus.if.org Git - clang/commitdiff
[PCH] In HeaderFileInfoTrait::EqualKey(), use FileManager::getFile() to compare two...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 4 Mar 2013 20:33:40 +0000 (20:33 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 4 Mar 2013 20:33:40 +0000 (20:33 +0000)
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

include/clang/Serialization/ASTReader.h
lib/Serialization/ASTReader.cpp

index 297b577eee4ed22a0e2d8c7a75356c48c9d13932..2744865819503e99d19eca9b4545493c798fda16 100644 (file)
@@ -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.
index e6ef9f64413cfc8b53cbae86fd739a4488c15ad0..4a4f2aaf912ae57e7e7141cbca971d47553d2467 100644 (file)
@@ -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<unsigned, unsigned>